I have a form. Inside the form, I have a datatable. Below you may find my code:
<p:column headerText="Extra request">
<p:commandButton id="requestDetailsButton" value="details" type="button"
update="detailPanel"
action="#{enbBean.sendEnbDetailsRequest(selectedEnbData.eNbAddress)}"
onclick="enbDetailsDialog.show()">
<f:setPropertyActionListener id="rowSelected" value="a" target="#{enbBean.selectedEnbData}" />
</p:commandButton>
</p:column>
The problem is that I need to set the command button with type=submit
. But when I do this then the entire page breaks. Why it breaks and how could I overcome this problem?
You may try this:
<p:commandButton id="requestDetailsButton" value="details"
update="detailPanel"
action="#{enbBean.sendEnbDetailsRequest}"
oncomplete="enbDetailsDialog.show()">
<f:setPropertyActionListener value="a" target="#{enbBean.selectedEnbData}" />
</p:commandButton>
public void sendEnbDetailsRequest() {
...
}
setPropertyActionListener will set #{enbBean.selectedEnbData} before action is called
Or you may try something like this:
<p:commandButton id="requestDetailsButton" value="details"
update="detailPanel"
actionListener="#{enbBean.sendEnbDetailsRequest}"
oncomplete="enbDetailsDialog.show()">
<f:attribute name="selectedEnbData" value="a"/>
</p:commandButton>
public void sendEnbDetailsRequest(ActionEvent ae) {
String selectedEnbData = (String)ae.getComponent().getAttributes().get("selectedEnbData");
...
}