I use primefaces version 6.2 in combination with jsf and trinidaad. In the project I have a table with each row containing a button to redirect this page to another page based on selected row. jsf and trindad commandLink and commandButton does the job but primefaces commandLink and command button doesn't.
What I have already done:
type="button"
immediate="true"
actionListener="#{coolingBean.view(row)}"
instead of action="#{coolingBean.view}"
.Anyone know why and what should I change?
<p:column id="viewButtonColumn" exportable="false" style="text-align: center" >
<tr:commandLink textAndAccessKey="&view " id="viewButton" action="#{coolingBean.view}" styleClass="commandLinkMediumSmallFont" onclick="PF('bui').show()">
<tr:image source="/imgs/view.png" styleClass="commandLinkImageWithText"/>
<f:setPropertyActionListener value="#{row.number}" target="#{coolingBean.criteria.number}"/>
<f:setPropertyActionListener value="#{row.id}" target="#{searchBean.selectedId}"/>
</tr:commandLink>
</p:column>
<p:column id="viewButtonColumn1" exportable="false" style="text-align: center" >
<h:commandLink textAndAccessKey="&view " id="viewButton1" action="#{coolingBean.view}" styleClass="ui-priority-primary" onclick="PF('bui').show()">
<i class="fa fa-search" ></i>
<f:setPropertyActionListener value="#{row.number}" target="#{coolingBean.criteria.number}"/>
<f:setPropertyActionListener value="#{row.id}" target="#{searchBean.selectedId}"/>
</h:commandLink>
</p:column>
<p:column id="viewButtonColumn2" exportable="false" style="text-align: center" >
<p:commandLink value="View" id="commandLinkView" action="#{coolingBean.view}" styleClass="ui-priority-primary" onclick="PF('bui').show()">
<i class="fa fa-search" ></i>
<f:setPropertyActionListener value="#{row.number}" target="#{coolingBean.criteria.number}"/>
<f:setPropertyActionListener value="#{row.id}" target="#{searchBean.selectedId}"/>
</p:commandLink>
</p:column>
<p:column id="viewButtonColumn3" exportable="false" style="text-align: center" >
<p:commandButton id="viewButton2" value="View" action="#{coolingBean.view}" icon="fa fa-search" immediate="true" type="button" onclick="PF('bui').show()">
<f:setPropertyActionListener value="#{row.number}" target="#{coolingBean.criteria.number}"/>
<f:setPropertyActionListener value="#{row.id}" target="#{searchBean.selectedId}"/>
</p:commandButton>
</p:column>
Inside managed Bean
public String view(Row selectedRow) {
if(criteria == null)
criteria = new criteriaBean();
criteria.setNummer(selectedRow.getNummber());
searchBean.selectedId = selectedRow.getId();
//FacesContext.getCurrentInstance().getExternalContext().dispatch("view.jsp");
return view();
}
public String view(){
return"view';
}
This one actually helped me.
Basically adding one of the following did the trick for me:
ajax="false"
into the commandButton?faces-redirect=true
to the url ( e.g. return "view?faces-redirect=true';
)