p:commandLink action only working for first link [duplicate] - jsf

This question already has an answer here:
<h:form> within <ui:repeat> not entirely working, only the last <h:form> is processed
(1 answer)
Closed 7 years ago.
Here is my XHTML code :
<ui:repeat var="clinic" value="#{searchController.clinicsViewList}">
<h:form rendered="#{clinic.timingSlot.size() gt 0 ?true:false}" id="lessSlotForm">
<p:scrollPanel style="height:55px;overflow:hidden;overflow-x: scroll;white-space: nowrap;">
<ui:repeat var="slot" value="#{clinic.timingSlot}">
<p:commandLink value="#{slot.slotTime}"
action="#{appController.bookAppointmentSlot(slot , clinic)}"
disabled="#{slot.active eq 'true'?false:true}"
style="margin:5px;" >
</p:commandLink>
</ui:repeat>
</p:scrollPanel>
</h:form>
</ui:repeat>
Here is <ui:repeat> to display different clinics, in side <ui:repeat> is to display time slots for each clinics.
Here is inside <ui:repeat>, <p:commandLink> has action to display all time slots for clinic.
But here got displayed list of timeslots for all clinics. but when i click on 1st clinic timeslots(<p:commandLink>) is working fine.
but 2nd clinic time slots(<p:commandLink>) not working.
Can any one tell me what is the reason.

This is happing because your h:form is inside ui: repeat keep your form outside of ui: repeat

Related

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.

The rerendered attribute not working on a4j:commandButton [duplicate]

This question already has an answer here:
Why do I need to nest a component with rendered="#{some}" in another component when I want to ajax-update it?
(1 answer)
Closed 7 years ago.
I'm using JSF 1.2 and RichFaces in my project. I'm trying to implement a scenario which is as follows, I have two rich:panel in my page and their rendered attribute is set to a boolean variable in a bean and the default values of the variable is set to false, so the first time the page is loaded the panels do not get rendered. I have a a4j:commandButton in my page and on the action attribute of the button I am calling a method in my bean which sets the two flag variable but the panels are not getting rendered even after the variables are set, and I am also setting the rerendered attribute of the button, I don't think I am missing any steps.
If component is not rendred when page is loaded then it will not make any change even when you will change the value of boolean variable to true on some commanad button click as well. Your component should be in view to rendered on Button click . So put your component inside another component Please chek below code
Following will not work when #{bean.renderResult} defaults to false:
<h:form id="form">
<h:commandButton value="Submit" action="#{bean.toggleRenderResult}">
<f:ajax render=":result" />
</h:commandButton>
</h:form>
<h:outputText id="result" value="#{bean.result}" rendered="#{bean.renderResult}" />
You need to ensure that the render ID points to a component which is already present in the JSF-generated HTML output.
Following will work:
<h:form id="form">
<h:commandButton value="Submit" action="#{bean.toggleRenderResult}">
<f:ajax render=":result" />
</h:commandButton>
</h:form>
<h:panelGroup id="result">
<h:outputText value="#{bean.result}" rendered="#{bean.renderResult}" />
</h:panelGroup>
For more information check http://balusc.blogspot.in/2011/09/communication-in-jsf-20.html#AjaxRenderingOfContentWhichIsByItselfConditionallyRendered

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 update panel from datatable [duplicate]

This question already has answers here:
How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar"
(6 answers)
Closed 7 years ago.
Commandbutton with id("myButtonId2") works fine. I mean it updates "myOutputPanel" but commandbutton which is inside datatable doesn't update outputPanel. Is there a specific update style for datatables?
<h:form id="myForm" prependId="false">
<p:panel id="myPanel">
<p:dataTable id="myDatatable">
<p:column style="width:4%">
<p:commandButton id="myButtonId" update="myOutputPanel"/>
</p:column>
</p:dataTable>
<p:commandButton id="myButtonId2" update="myOutputPanel"/>
</p:panel>
<p:outputPanel id="myOutputPanel">
//some stuff
</p:outputPanel>
This is because with process and update they work much the same way as the f:ajax component attributes execute and render do. One can only reference the id of a component directly if they reside within the same NamingContainer.
The clientID is generated by prefixing the naming container ids seperated by : by default. The p:panel component does not implement NamingContainer although h:form and p:dataTable do implement NamingContainer.
The clientID of myOutputPanel is as follows:
myForm:myOutputPanel
The second button works because it is outside of the dataTable and relative to myOutputPanel in the same NamingContainer which is the form. To reference the absolute clientID in process or update one can prefix the clientID with the : symbol.
Try changing the update attribute of the first commandButton to:
:myForm:myOutputPanel
This should allow it absolutely reference its generated clientID and work.

Resources