I have this dataTable:
<h:dataTable value="#{orderController.orderList}" var="order"
styleClass="table table-striped">
<h:column>
<f:facet name="header">#</f:facet>
<h:outputText value="#{order.orderNo}" escape="false"/>
</h:column>
<h:column>
<f:facet name="header">Cliente</f:facet>
<h:outputText value="#{order.client}" escape="false"/>
</h:column>
<h:column>
<f:facet name="header">Data</f:facet>
<h:outputText value="#{order.date}" escape="false"/>
</h:column>
<h:column>
<f:facet name="header">Status</f:facet>
<h:outputText value="#{order.status}" escape="false"/>
</h:column>
<h:column>
<f:facet name="header"></f:facet>
<h:form>
<h:commandButton action="#{orderController.orderDetail}" value="Detalhe" styleClass="btn btn-info"/>
</h:form>
</h:column>
</h:dataTable>
I’m showing a list of orders and each list has a button “Detail” that will redirect the user to the orderDetail.html page inside views/fornecedores.
I’ve debugged and when I click on the commandButton, it is not calling my bean function.[
I have also tried this: <h:commandButton action="views/fornecedores/orderDetail.html" value="Detalhe" styleClass="btn btn-info"/> and nothing, it keeps redirecting me to the same page, orderSearch.html.
What I need is to call the method that will receive a orderNo parameter and will load the object and redirect to the orderDetail.html page.
What am I doing wrong or what is the best way to this approach?
In this particular case, that can happen when you’re nesting forms which is illegal in HTML. This can also happen when the
#{orderController}is request scoped and theorderListcontent depends on a request based value which causes that the list is incompatibly changed when the form submit is to be processed.So, make sure that you aren’t nesting multiple
<h:form>components in each other and make sure that the#{orderController}is a@ViewScopedbean and that you aren’t manipulating theorderListin its getter method.See also:
As to your concrete functional requirement, the
<h:link>with<f:param>and<f:viewParam>is a more sane approach for this. It’s bookmarkable and more SEO friendly. See also Communication in JSF 2.0 – Processing GET request parameters.