0

My code:

<h:form id="form"> <p:dataTable var="article" value="#{articleTable.articles}" lazy="true" selection="#{articleTable.selected}" selectionMode="single" emptyMessage="#{text['emptyMessage']}" rowKey="#{article.id}"> <p:column style="display:none;"> <h:outputText value="#{article.id}" /> </p:column> <p:column headerText="#{text['titleText']}"> <h:outputText value="#{article.title}" /> </p:column> <p:column headerText="#{text['summaryText']}"> <h:outputText value="#{article.summary}" /> </p:column> <p:column headerText="#{text['categoryText']}"> <h:outputText value="#{article.category}" /> </p:column> <p:column headerText="#{text['statusText']}"> <h:outputText value="#{article.status.text}" /> </p:column> <p:ajax event="rowSelect" oncomplete="handleRowSelect('#{article.id}')"/> </p:dataTable> </h:form> 
 <script type="text/javascript"> function handleRowSelect(id) { if ( id ) window.location.href = 'article.xhtml?id=' + id; } </script> 

#{article.id} has value, but "handleRowSelect('#{article.id}')" argument value is '' empty.

I use Chrome F12; it has called handleRowSelect() method, but the id value is '' empty; why?

Why the argument is empty?

And how do I fix it?

Do I have to use commandLink or commandButton? Can't I click on a row to redirect page?

4
  • No one answer me... I found 2 way solution: 1. <p:ajax event="rowSelect" listener="#{articleTable.navigateToDetail}"/> But it turn back to redirect. 2. <p:dataTable id="articleTable" widgetVar="articleTable"> and var id = PF('articleTable').selection;. Why not each row call redirect method with id itself?
    – Robert
    CommentedSep 28, 2024 at 10:28
  • Can you share the lazyload function?CommentedSep 30, 2024 at 8:26
  • I answered your question here on why you are using the component incorrectly: github.com/orgs/primefaces/discussions/2765
    – Melloware
    CommentedSep 30, 2024 at 18:00
  • @ÖmerFarukKurt I didn't implement the lazy relate function, but I remain lazy property; excuse me. You can visit the link '2765' above refer for executable example, thanks. :)
    – Robert
    CommentedOct 1, 2024 at 7:54

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.