primefaces commandbutton update does not work [duplicate] - jsf

This question already has answers here:
commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated
(12 answers)
Closed 2 years ago.
I have minimized my code to better show you what is not working.
<h:body>
<f:view>
<h:form id="wbSelectForm">
<p:commandButton id="viewWorkbenchButton" icon="ui-icon-show"
title="View Workbench" update=":wbTestPanel"
actionListener="#{WorkbenchControllerBean.test}">
</p:commandButton>
</h:form>
<p:panel id="wbTestPanel">
Test: Active Wb: #{WorkbenchControllerBean.number}
</p:panel>
</f:view>
</h:body>
When i press the commandButton, i would expect that 'wbTestPanel' is being updated, which does somehow NOT happen. I know that because WorkbenchControllerBean.getNumber() is not called.
I am using primefaces 3.5. I already tried differend values for 'process'-attribute as well as putting RequestContext.getCurrentInstance().update("wbTestPanel")in WorkbenchControllerBean.test()-method.
I think that maybe the code is right, but there are any settings in the project or runtime environment (Java 7 + JBoss 7.1.1) that prevent primefaces from updating the other panel. Could you please give me a hint what to search for?
Thanks in advance!

Are you sure that test() method is invoked?
If yes, can you try with following update expression?
update="#([id$=wbTestPanel])"
Otherwise, it maybe the case that test() method is not called because of a validation error. If that is the case, you can inspect it with debug or firebug.

Use : before id
Remember
If you make a dialog.
Before Dialog old form tag should be closed.
Then dialouge content should be placed into another form.
Use update=":dialougeid, :dialougeFormId"

Related

commandLink does not call action method with correct backingBean [duplicate]

This question already has answers here:
commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated
(12 answers)
Closed 5 years ago.
I am working with JSF trying to do a .xhtml as simple as :
<ui:composition ...>
<span class="fr">
<a4j:commandLink value="#{msg.label_return}"
action="#{backingBeanRef['navigateBack']()}"
rendered="#{backingBeanRef['returnValueStackBean']['returnValueStack']['size']() ne 0}"
render="#{render}"/>
</span>
</ui:composition>
so I can include it in several views. It works as expected in most of them but one, in which the action method is never called.
I have tried to call the method without parameterization (#{myBean.navigateBack()}) and it still doesn't works.
I have also tried to write #{backingBeanRef'navigateBack'} above the commandLink and the method is called so the backingBeanRef is correct and everything should work but it doesn't.
At this point I have no clue about what is happening, does anyone knows?
Thanks in advance
I had two <h:form> in my code. Once I removed one of these, this got fixed.

p:selectBooleanCheckBox does not work inside a p:dialog [duplicate]

This question already has answers here:
Can you nest html forms?
(21 answers)
How to use <h:form> in JSF page? Single form? Multiple forms? Nested forms?
(2 answers)
Closed 6 years ago.
I'm using PrimeFaces 5.3 with the following code:
<p:dialog id="dlg1" appendTo="#(body)" header="Confirm Dialog" widgetVar="dlg1" modal="true">
<h:form id="dialogform">
<h:outputText id="confirmlabel" value="Are you Sure you want to #{reportRunnerNamedBean.currentCommand} ?" />
<br/>
<center>
Check to send only missed emails:<p:selectBooleanCheckbox id="sendOnlyMissedBox" value="#{reportRunnerNamedBean.sendMissedOnly}"></p:selectBooleanCheckbox><br/>
<p:commandButton id="yesButton" value="Yes" action="#{reportRunnerNamedBean.runCurrentCommand()}" onstart="startWait();PF('waitDialog').show();" oncomplete="PF('waitDialog').hide();stopWait();" onclick="PF('dlg1').hide();" process="#form"/>
<p:commandButton id="noButton" process="#this" value="No" onclick="PF('dlg1').hide();"/>
</center>
</h:form>
</p:dialog>
No matter what, the backing bean value for the sendMissedOnly is set to false. I have confirmed this by attaching a debugger. I have even tried adding ajax to the box, it is still false every time, no matter if it is checked or not. Does p:selectBooleanCheckbox just not work in a dialog?
I figured this out. It was because the dialog was in an form. It seems that when a dialog is in a form , and you have a form within the dialog itself, the component will not be processed. It seems JSF/primefaces does not like multiple layers of forms or dialogs defined within forms. If you are having a similar issue, makes sure your dialog is defined outside any form. Moving a dialog can cause paths to components to change. the easiest way to resolve that is to use the primefaces handy p:component tag like this update=":#{p:component('compoment_name')}" > that will make it find it no matter where in the tree the component occurs.

p:commandButton can't to update p:panel [duplicate]

This question already has an answer here:
How to update panel from datatable [duplicate]
(1 answer)
Closed 7 years ago.
I'm using PF 5.3, with JSF 2.2
I have a p:commandButton which exists in one of p:column of a p:dataTable. I have a panel outside the dataTable and I want it to be updated once the commandButton is clicked, but this didn't work.
xhtml sample:
<h:form id="register_edit_student" enctype="multipart/form-data" >
<p:dataTable var="students" value="#{generalPresentation.students}">
<p:column headerText="Edit">
<p:commandButton update="updateStudent" value="Edit" action="#{teacherPresentation.assignEditableStudent(students)}" />
</p:column>
</p:dataTable>
<p:panel id="updateStudent">
</p:panel>
</h:form>
My requirement is to update the "updateStudent" p:panel.
Once I ask the p:commandButton to update the panel (update="updateStudent") the page design crashed and all controls disappeared.
I was reading in the internet the commandButton of a column in a dataTable cannot update anything outside the dataTable, so the question, is there a solution or work around?
Thanks
You have three options to solve this:
add prependId="false" to your form,
Prepend the form id in your reference: update=":register_edit_student:updateStudent" or
move your panel outside of the form element.
Note: The first option should be used rarely and is known to cause issues with plain JSF.

a4j:commandButton's action is never triggered when it's inside a rich:panel with rendered tag [duplicate]

This question already has answers here:
commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated
(12 answers)
Closed 8 years ago.
Here is the simplified version of my xhtml code, I can't figure out why my save1 commandButton doesn't work while save2 works:
<rich:panel id="table_panel">
<h:form>
<rich:panel rendered="#{bean.showPanel}">
<a4j:commandButton id="save1" value="Save"
action="#{bean.executeAction()}">
</rich:panel>
<rich:panel>
<a4j:commandButton id="save2" value="Save2"
action="#{bean.executeAction()}">
</rich:panel>
</h:form>
</rich:panel>
When click a button, it will update showPanel value to true in backend and re-render *table_panel*,
then commandButton save1 will show up, but even if it show up, the action executeAction()
will never be invoked after click (never enter into my breakpoint in the method). However, the commandbutton save2 can always act normally.
The only difference for those two buttons is their wrapper rich:panel, one is always there while
another is displayed after some UI action as it has rendered="#{bean.showPanel}" attribute. I didn't see any javascript errors on firebug.
I would appreciate any ideas, thanks in advance!
Try putting execute="#this" explicitly in the commandButton.
Have you tried immediate="true", it might narrow down the issue in my opinion:
<a4j:commandButton id="save1" value="Save" immediate="true"
action="#{bean.executeAction()}">

How to pass parameters panelgroup - binding, JSF [duplicate]

This question already has answers here:
How does the 'binding' attribute work in JSF? When and how should it be used?
(2 answers)
Closed 8 years ago.
I have a datatable that reads registers from a database.
In the datatable I have a panelgroup that is populated by binding
My problem is that I can not pass a parameter. I want to pass a value from the datatable variable, in that case preg, on each row I want to know the value of the register read to populate the panelgroup.
If I display the value it works fine for each row: #{preg.idpreg}
<h:dataTable var="preg" value="#{Pregbacking.list(Pregbacking.idenq)}">
<h:column>
#{preg.idpreg}
<h:panelGroup binding="#{Pregbacking.dynamicDataTableGroup(preg.idpreg)}"/>
</h:column>
</h:dataTable>
Does anybody know how can I solve this?
That should work just find but I believe that you need to make sure you are using a modern servlet spec (v3 I think). Use the latest Glassfish or Tomcat app server.

Resources