Primefaces SelectOneMenu's ajax event inside outputPanel with rendered, is not working [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 3 years ago.
I've this code:
<p:outputPanel styleClass="ep-form-field-wrapper-s" rendered="#{monthlyProcessesReportsViewBean.showReports}">
<p:outputLabel for="columnsConfig" value="#{i18n['monthly-processes-reports-columns-configuration']}" styleClass="ep-data-edit-field"/>
<p:selectOneMenu id="columnsConfig" value="#{monthlyProcessesReportsModelBean.report}" effect="none" converter="#{genericUniqueEntityConverter}">
<f:selectItem itemValue="#{null}" itemLabel="#{i18n['monthly-processes-reports-as-payslip']}"/>
<f:selectItems value="#{monthlyProcessesReportsModelBean.reports}" var="report" itemValue="#{report}"
itemLabel="#{report.description}"/>
<p:ajax listener="#{monthlyProcessesReportsBackingBean.handleReportTypeSelected(report)}"/>
</p:selectOneMenu>
</p:outputPanel>
The ajax event is not working, but if I remove the rendered attribute from the outputPanel it works correctly.
What is wrong in my code?
Thanks!

Thank you for the link.
These are the dangers of the copy&paste: my monthlyProcessesReportsViewBean, which is used to store the property that manages the rendered attibute, was RequestScoped instead of ViewScoped and I'd not been noticed...

Related

How I can use a converter in a JSF tag selectOneMenu? [duplicate]

This question already has answers here:
How to populate options of h:selectOneMenu from database?
(5 answers)
Closed 4 years ago.
The following example works in my interface:
<h:outputText value="#{diplome.pays}">
<gn:converter origine="#{config.origManSirhen}"
nomenclature="#{config.codePays}"
propriete="libelleImpression" />
</h:outputText>
However, when I try to use the same converter does not work when the element is a selectOneMenu
<p:selectOneMenu id="pays">
<f:selectItem
itemValue="#{InformationsPersonnellesModele.adressePrincipale.pays}"
itemLabel="#{InformationsPersonnellesModele.adressePrincipale.pays}" />
<gn:converter origine="#{config.origManSirhen}"
nomenclature="#{config.codePays}" propriete="libelleImpression" />
</p:selectOneMenu>
I have tried to use the attribute converter into the selectOneMenu tag, but it does not work as I expect because I need to use as well the parameter nomenclature and propiete.
I found a possible solution:
The item selected by default must be the value of the selectOneMenu tag.
And the list of items and the converter are directly assigned to the value of the selectItems tag.
<p:selectOneMenu id="pays"
value="#{InformationsPersonnellesModele.adressePrincipale.pays}">
<f:selectItems
value="#{gnl:listeTri(config.origManSirhen, config.codePays,'libelleImpression')}" />
</p:selectOneMenu>

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.

Conversion Error setting value '1' for 'null Converter' [duplicate]

This question already has answers here:
How to populate options of h:selectOneMenu from database?
(5 answers)
Closed 7 years ago.
When I click submit button in a jsf page I get the above error.
html:
<h:selectOneMenu id="ddlCountryCode" value="#{jsfFills.countries}">
<f:selectItems value="#{jsfFills.countries}" var="c"
itemLabel="#{c.CName}" itemValue="#{c.CCode}" />
</h:selectOneMenu>
The "value" attribute should point to a variable where you want to store the selected value of the component, not the list of choices.
In the example above, jsfFills.countries is used as both the list of options AND the value of the component, and that could be causing the issue. We'd want to create a variable in a bean somewhere and use that instead.
<h:selectOneMenu id="ddlCountryCode" value="#{jsfFills.selectedCountry}">
<f:selectItems value="#{jsfFills.countries}" var="c"
itemLabel="#{c.CName}" itemValue="#{c.CCode}" />
</h:selectOneMenu>

<h:outputText> rendered the old value even after ajax update [duplicate]

This question already has an answer here:
Ajax update/render does not work on a component which has rendered attribute
(1 answer)
Closed 8 years ago.
In below code, I click the Submit button. That change boolean result value to true in backing_home bean via a ajax call.
If I remove the rendered rendered="#{backing_home.result}", I see the updated output properly.
But with the below code it is false. I think it doesn't render the new value
<h:commandButton id="MySubmit" value="Submit" action="#{backing_home.toggleRenderResult}">
<f:ajax render=":AjaxGuess:result2"/>
</h:commandButton>
<h:outputText id="result2" value="#{backing_home.result}" rendered="#{backing_home.result}" />
What could be the reason?
I update the code as below based on Hatem Alimam's comment.
<h:commandButton id="MySubmit" value="Submit" action="#{backing_home.toggleRenderResult}">
<f:ajax render=":AjaxGuess:result2"/>
</h:commandButton>
<h:panelGroup id="result2">
<h:outputText value="#{backing_home.result}" rendered="#{backing_home.result}" />
</h:panelGroup>

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()}">

Resources