I got an issue for a while and I can't get rid of it. In my data table I have a column with a button to display a dialog with further information on click.
When I click the first time on the button the dialog opens with the right values, but when I click a second time on button of the same row or any other the values aren't displayed because my event handler findStfPack
receive a null value attribute.
I tried to pass the PackageData
object to be displayed directly to the method as parameter:
<p:column width="60">
<p:commandButton oncomplete="PF('dlgViewStfPack').show()"
update="search:dlgViewStfPackId"
value=""
title="#{msg['button.search']}"
action="#{budgetViewFulfiledController.findStfPack(_item.stfPack)}"
process="@this"/>
</p:column>
Handler method in view controller:
public void findStfPack(PackageData event){
System.out.println("event: "+event.getPackId());
stfPack= event;
}
Or with primefaces action event:
<p:column width="60">
<p:commandButton oncomplete="PF('dlgViewStfPack').show()"
update="search:dlgViewStfPackId"
value=""
title="#{msg['button.search']}"
actionListener="#{budgetViewFulfiledController.findStfPack}"
process="@this">
<f:attribute name="pack" value="#{_item.stfPack}"/>
</p:commandButton>
</p:column>
Handler method in view controller:
public void findStfPack(ActionEvent event){
PackageData packageData= (PackageData)event.getComponent().getAttributes().get("pack");
System.out.println("event: "+packageData.getPackId());
stfPack= packageData;
}
The dialog:
<p:dialog id="dlgViewStfPackId"
header="#{budgetViewFulfiledController.stfPack.staff.stfName} - Package salarial"
modal="true"
widgetVar="dlgViewStfPack">
<div class="groupDataBox">
<my:outputCurrentPackage currPack="#{budgetViewFulfiledController.stfPack}"/>
</div>
</p:dialog>
And the outcome is the same in the 2 scenarios: on the first event trigger the value is properly passed and displayed but on the second event trigger I got a NullPointerException
.
I should specify that, I don't know why but without the update="search:dlgViewStfPackId"
the values are not displayed in the dialog.