I am using Primefaces 4.0.
Problem i am facing is CommandLink not Getting updated on change event of SelectOnemenu.Code as Follows:-
<p:selectOneMenu id="List"
value="#{Bean.selectedId}" style="width:230px">
<f:selectItem itemLabel="--Select--" />
<f:selectItems value="#{Bean.SelectItemList}" />
<p:ajax event="change" update="enableGo,disableGo"></p:ajax>
</p:selectOneMenu>
<p:commandLink id="enableGo" value="GO" styleClass="blueButton"
rendered="#{Bean.selectedId != null}"
action="#{note.load}">
</p:commandLink>
<p:commandLink id="disableGo" value="GO"
styleClass="disabledButton"
rendered="#{Bean.selectedId == null}">
</p:commandLink>
I also tried updating with the formid eg: ":formid:enableGo,:formid:disableGo" but it didnt work!.
The client side javascript won't be able to find either of the components to update. You'll need to wrap them (the <p:commandLink>s) in a wrapper and then update the wrappers. See BalusC's answer for more details and an example.
Related
I have a view which contain the following fields:
<p:selectOneMenu style="width:40px" value="#{capacityFamilyBean.capacityFamily.bottleneck}">
<f:selectItems value="#{capacityFamilyBean.availableCapFamilyBottlenecks()}"/>
</p:selectOneMenu>
<p:inputText id="capacityFamilyName" binding="#{capacityFamilyName}" style="margin-left:20px" value="#{capacityFamilyBean.capacityFamily.name}">
<p:ajax event="change" update="newBundleButton"/>
</p:inputText>
<p:commandButton id="newBundleButton" icon="ui-icon-plus" disabled="#{empty capacityFamilyName.value}" value="${msgs.New}" oncomplete="PF('capacityFamilyDialog').show();"/>
you can see the value properties are {capacityFamilyBean.capacityFamily.prprty}
capacityFamilyDialog uses the same properties, but they are not pre-filled
<p:selectOneMenu value="#{capacityFamilyBean.capacityFamily.bottleneck}">
<f:selectItems value="#{capacityFamilyBean.availableCapFamilyBottlenecks()}" />
</p:selectOneMenu>
<p:inputText id="capacityFamilyName" style="margin-left:20px" value="#{capacityFamilyBean.capacityFamily.name}"/>
I'm assuming they refer to different capacityFamily object, but how can I counter that?
The dialog is delivered with the page. So it's completely empty.
oncomplete="PF('capacityFamilyDialog').show();"
is pure javascript and only shows this empty popup. If you like to have a dialog with actual values, you have to update it in an ajax-call like your commandButton.
<p:commandButton value="${msgs.New}" update="capacityFamilyDialog_ID" oncomplete="PF('capacityFamilyDialog').show();"/>
The dialogue is functional when you click the button. I think you should update the id for dialogue box.
JSF Code
<p:commandButton id="impBtb"
process="#this" icon="ui-icon-plus" disabled="#{empty capacityFamilyName.value}"
value="${msgs.New}" oncomplete="PF('capacityFamilyDialog').show();" update="#form:capacityFamilyDialog">
</p:commandButton>
So, you may have to perform a ajax-call from your commandbutton to update the dialog box.
Hope it helps!!
Hi I am using PrimeFaces. I have a <p:calendar> in a dialog box and I would type date manual . But my date is not setting in bean's variable. It works for dataSelect event but don't work keypress or keydown event. I am wondering it is also working outside dialog box. Here is my code:
<p:calendar readonlyInput="false" id="Date1" rendered="true"
navigator="true" showButtonPanel="true"
styleClass="form-control cal_input" showOn="both"
pattern="#{sessionManager.defaultDateFormat.substring(0,11)}"
yearRange="#{appLabel['year_Range']}" tabindex="203"
value="#{mangeCreateOrdersTO.searchOrderPatientBean.DOB}"
disabled="false" mask="true"
maxdate="#{mangeCreateOrdersTO.maxDateOfBirth}"
autocomplete="#{appLabel['autoCompleteSetting']}"
onkeypress="return disableEnterKey(event)">
<p:ajax event="dateSelect" process="#this" partialSubmit="true" ignoreAutoUpdate="true" update="form:Date1"/>
<p:ajax event="keydown" process="#this" immediate="true" partialSubmit="true" ignoreAutoUpdate="true" listener="#{mangeCreateOrdersTO.add(mangeCreateOrdersTO.searchOrderPatientBean.DOB)}"/>
</p:calendar>
Please help me to get rid from this problem. Thanks in advance.
I found what was wrong. So:
My <p:Calendar> must be under the <h:form> which I was missing.
Environment:
Jboss 7.1.1.Final JSF 2.2.6 Seam 2.3.1.Final Richfaces 4.5.10.Final
Issue
Richfaces 4 extendeddatatable on render does not hold the value (Resource dropdown in the example listed below).
Steps:
First I choose a value from the Resource dropdown
Then I choose a value form the Result dropdown which triggers the a4j:ajax call
My XHTML structure is as listed below:
<a4j:region id="hraregion">
<rich:extendedDataTable id="hraProcessing"
value="#{maActionList}" var="mpa" selectionMode="single">
<h:column width="200px">
<f:facet name="header">
<h:outputText value="Resource" />
</f:facet>
<h:selectOneMenu id="staffResources" value="{mpa.staffResources}" label="Resource"
<s:selectItems value="#{mpa.validStaffResources}" var="sr" label="#{sr.firstName} #{sr.lastName}"/>
<s:convertEntity />
</h:selectOneMenu>
</h:column>
<rich:column width="140px">
<f:facet name="header">
<h:outputText value="Result" />
</f:facet>
<h:selectOneMenu id="results" value="#{mpa.actionResults}">
<a4j:ajax execute="region" listener="#{maintainAssessment.performNextAction(mpa, 'mpa')}" render="hraProcessing, actionMessage" />
<s:selectItems value="#{mpa.validActionResults}" var="ar" label="#{ar.name}" noSelectionLabel="Select One" />
<s:convertEntity />
</h:selectOneMenu>
</rich:column>
</rich:extendedDataTable>
</a4j:region>
Note:
We are migrating from Richfaces 3.3 to 4.5 and this functionality was working fine in Richfaces 3.3 but ofcourse the entire page was refreshed in 3.3 as opposed to the partial refresh in Richfaces 4.5
Can someone please point me in the right direction on how to retain the selected value after the a4j render happens?
I found a way to accomplish this by updating the backing bean immediately using f:ajax after the value changes in the Resource dropdown. Hope this helps someone who faces the same issue.
<h:selectOneMenu id="staffResources" value="#{mpa.staffResources}"
label="Resource" styleClass="LFloat">
<s:selectItems value="#{mpa.validStaffResources}" var="sr"
label="#{sr.firstName} #{sr.lastName}"/>
<s:convertEntity />
<f:ajax event="valueChange" execute="#this" render="#none"/>
</h:selectOneMenu>
I would like to update a component without processing it. I use a binding get the value of a checkbox and decide if the other component should be rendered. Unfortunately, the update? or the binding? doesn't work as i would.
<p:selectBooleanCheckbox id="isPercentage" value="#{myBean.isDiscountInPercentage}"
label="Percentage" binding="#{discountInPercentage}">
<p:ajax process="" update="outpDiscountValue" />
</p:selectBooleanCheckbox>
<p:outputPanel id="outpDiscountValue">
<h:outputLabel value="$" rendered="#{!discountInPercentage.value}" />
<h:outputLabel value="%" rendered="#{discountInPercentage.value}" />
</p:outputPanel>
below you see some part of my code, i just want to select the first value in a form and the rest should be updated via ajax, for example if you select PK than, MccName, MccVorname,MccDepartment should be shown via ajax after this selection.
This should also be possible in other forms indepently,
<h:panelGrid columns="4">
<h:form id="formmcc10">
<h:outputText value="Pls select PK: " />
<p:selectOneMenu value="#categorymcc.mcccatname}" id="mcccat"
immediate="true" valueChangeListener="#categorymcc.processScat}">
<f:selectItem itemLabel="#categorymcc.mcccatname}"itemValue="" />
<f:selectItems value="#categorymcc.categoryName}" />
<p:ajax update="formmcc10:mccscat1 formmcc10:mccscat2 formmcc10:mccscat3" event="change" />
</p:selectOneMenu><h:outputText value="Mcc Name" />
<p:selectOneMenu value="#{categorymcc.submcccatname}"id="mccscat1">
<f:selectItemsvalue="#{categorymcc.subCategoryName}" />
</p:selectOneMenu>
<h:outputText value="Mcc Vorname" />
<p:selectOneMenu value="#{categorymcc.subsubmcccatname}"id="mccscat2">
<f:selectItems value="#{categorymcc.subSubCategoryName}" />
</p:selectOneMenu>
<h:outputText value="Mcc Department:" />
<p:selectOneMenu value="#{categorymcc.abteilung}" id="mccscat3">
<f:selectItems value="#{categorymcc.abteilungCategoryName}" />
</p:selectOneMenu>
</h:form>
</h:panelGrid>
This could be anything, but I encountered one interesting problem like that recently. I tried to output a bean property like #{myBean.otherBean.name} and it worked when I loaded the page by normal request, but it didn't work with AJAX. When I tried #{myBean.otherBean.id}, it worked in both cases.
The problem was, that backend system didn't fill all data for otherBean on AJAX request, it filled only id (probably for better performance). I had to prepare a getOtherBeanById method and when I called that, AJAX started to work as expected.
I'm not an expert on this field, perhaps someone has a more precise explanation for that.