문제

p:commandLink action does not fire on my view bean. I tried many things but I did not achieve :(( There should be a simple issue about that. I would be appreciated if you can help me.

<p:dataTable var="message" value="#{messagesView.dataModel}"
     id="messageDt" emptyMessage="#{msg['kayitBulunamadi']}"
     lazy = "true" paginator="true" rows="10" 
        paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
        rowsPerPageTemplate="10,15,30" currentPageReportTemplate="{currentPage} / {totalPages}">

 <p:column styleClass="min-image">
        <f:facet name="header">
           <h:outputText value="Durum" />
        </f:facet>
        <p:commandLink ajax="true" process="@this"
           action="#{messagesView.selectedMessages(message)}"
           oncomplete="PF('msjDialog').show();">
           <!--<p:graphicImage  value="#{message.mesajDurumu=='NEW'?'/images/DealerNewMessages.png':'/images/DealerReadMessage.png'}" style="width: 60px; height: 60px;" />-->
           <p:graphicImage rendered="#{message.mesajDurumu=='REP'}"
              value="/images/email-send.png" style="width: 30px; height: 30px;" />
           <p:graphicImage rendered="#{message.mesajDurumu=='NEW'}"
              value="/images/DealerNewMessages.png"
              style="width: 30px; height: 30px;" />
           <p:graphicImage
              rendered="#{message.mesajDurumu!='REP' and message.mesajDurumu!='NEW'}"
              value="/images/DealerReadMessage.png"
              style="width: 30px; height: 30px;" />
        </p:commandLink>
     </p:column>

Bean Code :

public void selectedMessages(DealerMessages msj) {
  SELECTedMessage = msj;
  oncekiMesajiAl();
  UpdateMessageStatusRead(msj);
 }
도움이 되었습니까?

해결책

<p:commandLink> has to be nested inside a <h:form> to work properly.

다른 팁

Did you try to use:

actionListener="#{messagesView.selectedMessages(message)}"

instead of

action="#{messagesView.selectedMessages(message)}"

Maybe try this:

<p:commandLink ajax="true" process="@this"
           action="#{messagesView.selectedMessages}"
           oncomplete="PF('msjDialog').show();"> 

And get the value as:

... value = "#{messagesView.message} ....

MessagesView Bean code:

public void selectedMessages() {
  SELECTedMessage = getMessage();
  oncekiMesajiAl();
  UpdateMessageStatusRead(SELECTedMessage);
 }

What this is doing is that it is setting the variable on the bean through the value of your element. However, you need to make message a field variable inside you bean with a getter and setter; otherwise this won't work.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top