JSF 1.2 issue on commandButton - jsf

JSF 1.2 CommandButton not Working
<h:dataTable first="0" rows ="#{aptMgmtUIHandler.usocsOnFirstPanel}"
value="#{aptMgmtUIHandler.appt.usocList}" cellspacing = "3" var="usoc">
<h:column>
<h:outputText value="#{usoc.displayName}"></h:outputText>
<h:outputLabel value=":"></h:outputLabel>
</h:column>
<h:column rendered="#{usoc.displayName eq 'Ethernet Tech Install (1CRMM)'}">
<h:selectOneMenu value="#{usoc.usocQuantity}" style="height:22px"
rendered="#{usoc.booleanType}">
<f:selectItem itemLabel="NO" itemValue="#{aptMgmtUIHandler.no}" />
<f:selectItem itemLabel="YES" itemValue="#{aptMgmtUIHandler.yes}" />
</h:selectOneMenu>
<h:inputText value="#{usoc.usocQuantity}" style="height:17px"
rendered="#{!usoc.booleanType}"
onchange="return isNumeric(this.value, '#{usoc.displayName}')">
</h:inputText>
</h:column>
<h:column rendered="#{usoc.displayName ne 'Ethernet Tech Install (1CRMM)'}">
<h:selectOneMenu value="#{usoc.usocQuantity}" style="height:22px"
rendered="#{usoc.booleanType}" >
<f:selectItem itemLabel="NO" itemValue="#{aptMgmtUIHandler.no}" />
<f:selectItem itemLabel="YES" itemValue="#{aptMgmtUIHandler.yes}" />
</h:selectOneMenu>
<h:inputText value="#{usoc.usocQuantity}" style="height:17px"
rendered="#{!usoc.booleanType}"
onchange="return isNumeric(this.value, '#{usoc.displayName}')">
</h:inputText>
</h:column>
</h:dataTable>
<h:commandButton id="nextAdd" value="Next" styleClass="button"
action="#{aptMgmtUIHandler.getCalendarFromCTS}"></h:commandButton>
My Bean Scope in xml is session. After clicking on the button its not calling the backbean method.
Its not showing any Error message. After removing the render its calling the method.

Related

f:ajax doesn't update component

I have a select and I want that when the user doesn't select anything it prints an error. So I use validator and my xhtml code is:
<p:selectOneMenu id="students"
value="#{studentsBean.selectedStudent}"
converter="studentsConverter" effect="fold">
<f:selectItem itemLabel="Select..." itemValue="" />
<f:selectItems value="#{studentsBean.studentsList}"
var="student" itemValue="#{student}"
itemLabel="#{student.name}" />
<p:ajax event="change" update="students" process="#this" />
<f:validator validatorId="studentNotNull" />
<f:ajax execute="#this" render="studentPanel"/>
</p:selectOneMenu>
<h:panelGroup id="studentPane">
<h:message for="students" style="color:red" />
</h:panelGroup>
The problem is that if I don't select anythin it print me "The students is not selected" while I choice an student the label it doesn't disappear.
the validatior works and I don't think I must write the code.
Anyone can help?
Can you try this
<p:selectOneMenu id="students"
value="#{studentsBean.selectedStudent}"
converter="studentsConverter" effect="fold"
required="true" requiredMessage="Student is required">
<f:selectItem itemLabel="Select..." noSelectionOption="true"/>
<f:selectItems value="#{studentsBean.studentsList}"
var="student"
itemValue="#{student}"
itemLabel="#{student.name}" />
</p:selectOneMenu>
Add in your form
<p:growl id="msgs" showDetail="true" life="3000"/>
and of course, update msgs in form submit

Primefaces commandButton actionListener not working inside notificationBar

I am using PF 5.2 for the web app. I wanted to use notificationBar to reside some data inputs and commandButton to trigger these inputs data to the backing bean. Therefore I put a commandButton inside the notificationBar but actionListener is not calling the backing bean method. CommandButton is defined with id of "filterBtn".
The .xhtml page code is in the below:
<h:form>
<p:notificationBar position="top" effect="slide" styleClass="top" widgetVar="bar" style="height:200px;">
<h:panelGrid columns="1">
<h:panelGrid id="filterGrid1" columns="4" >
<h:outputLabel id="vhclIdLbl" value="#{general.vehicleId}"/>
<p:inputText id="fMtsId" value="#{notifyBean.fMtsId}" style="width:200px"/>
<h:outputLabel id="serialNoLabel" value="#{general.serialNo}"/>
<p:inputText id="fSerialNo" value="#{notifyBean.fSerialNo}" style="width:200px"/>
<h:outputLabel id="brandLbl" value="#{general.brand}"/>
<p:selectCheckboxMenu id="fBrand" value="#{notifyBean.fBrands}" effect="slide" style="width:210px"
appendTo="#this">
<f:selectItem itemLabel="#{general.pleaseSelect}" itemValue=""/>
<f:selectItems value="#{notifyBean.brandList}"/>
</p:selectCheckboxMenu>
<h:outputLabel id="modelLabel" value="#{general.model}"/>
<p:selectCheckboxMenu id="fModel" value="#{notifyBean.fModels}" effect="slide" style="width:210px"
appendTo="#this">
<f:selectItem itemLabel="#{general.pleaseSelect}" itemValue=""/>
<f:selectItems value="#{notifyBean.modelList}"/>
</p:selectCheckboxMenu>
<h:outputLabel id="provLabel" value="#{general.province}"/>
<p:selectCheckboxMenu id="fProvince" value="#{notifyBean.fProvinces}" effect="slide" style="width:210px"
filter="true" filterMatchMode="startsWith" appendTo="#this">
<f:selectItem itemLabel="#{general.pleaseSelect}" itemValue=""/>
<f:selectItems value="#{notifyBean.provinceList}"/>
</p:selectCheckboxMenu>
<h:outputLabel id="regionLabel" value="#{general.region}"/>
<p:selectCheckboxMenu id="fRegion" value="#{notifyBean.fRegions}" effect="slide" style="width:210px"
appendTo="#this">
<f:selectItem itemLabel="#{general.pleaseSelect}" itemValue=""/>
<f:selectItems value="#{notifyBean.regionList}"/>
</p:selectCheckboxMenu>
</h:panelGrid>
<p:commandButton id="filterBtn" value="Filter" actionListener="#{notifyBean.filterByProperties()}" icon="ui-icon-arrow-1-n"/>
<p:commandButton value="Hide" onclick="PF('bar').hide()" type="button" icon="ui-icon-arrow-1-n"/>
</h:panelGrid>
</p:notificationBar>
</h:form>
I know it is a simple use of the components but it is not working. Any help?
The notificationBar should not be embedded in a form. Just exchange the notificationBar and form tags, so the form is within the notificationbar.
<p:notificationBar position="top" effect="slide" styleClass="top" widgetVar="bar">
<h:form>
<p:commandButton value="yes" actionListener="#{backingBean.onDeleteButton}" onclick="PF('bar').hide()" />
<p:commandButton value="no" onclick="PF('bar').hide()" />
</h:form>
</p:notificationBar>

disabled value getting null in bean for p:selectOneMenu

I want to disabled department field based on employeeno.But,I want department value in bean.When,I using disabled value getting null in bean but without using disabled no problem...
<h:outputText value="Employee No"/>
<p:selectOneMenu value="#{salarypromotionBean.salarypromotiondto.employeeNo}" id="emp" style="width:163px;">
<f:selectItem itemLabel="select" itemValue="0" />
<f:selectItems value="#{salarypromotionBean.empid}"/>
<p:ajax event="change" listener="#{salarypromotionBean.currentSalaryAmount}" update="salaryIncrement,empN,empDoj,basic,da,empNewDesig,commonSalaryIncrement"/>
</p:selectOneMenu>
<h:outputText value="Department" />
<p:selectOneMenu value="#{salarypromotionBean.salarypromotiondto.department}" id="empDept" disabled="#{salarypromotionBean.designationDiaspleValue}"
style="width:163px;">
<f:selectItems value="#{salarypromotionBean.deptname}" />
</p:selectOneMenu>
You can do this.
<p:selectOneMenu value="#{salarypromotionBean.salarypromotiondto.department}" id="empDept" rendered="#{!salarypromotionBean.designationDiaspleValue}"
style="width:163px;">
<f:selectItems value="#{salarypromotionBean.deptname}" />
</p:selectOneMenu>
<p:inputText value="#{salarypromotionBean.salarypromotiondto.department}" readonly="true" rendered="#{salarypromotionBean.designationDiaspleValue}"/>

JSF selectonemenu does not update

i am beginner in JSF ,i have a problem with selectonemenu item.When i choose the an item ,for example ' FirstLabel',outputpanel should be shown.However ,selectone menu does not update my choice.I use primefaces 3.1 library.How can i solve this problem.Thanks for helps.
<p:selectOneMenu value="#{denemeView.str}" effect="fold" editable="true" >
<f:selectItem itemLabel="Please choose!." itemValue="" />
<f:selectItem itemLabel="FirstLabel" itemValue="1" />
<f:selectItem itemLabel="SecondLabel" itemValue="2" />
<p:ajax process="#this" update=":Form2:panel1"/>
<p:ajax process="#this" update=":Form2:panel2"/>
</p:selectOneMenu>
</p:outputPanel>
<p:outputPanel id="panel1" rendered="#{denemeView.str=='1'}">
<h:outputText value="Output: * " />
<p:inputText id="out" value="#{denemeView.islem}" />
</p:outputPanel>
<p:outputPanel id="panel2" rendered="#{denemeView.str=='2'}">
<h:outputText value="True choice! " />
</p:outputPanel>
If a JSF component has rendered="false" set then it's not redered (the component object is not present in the object tree) and cannot be updated using <p:ajax update="someId"/> or <f:ajax render="someId"/>. What you need to do is wrap these two panels in an outer panel and update that one. Something like this:
<p:ajax process="#this" update="outerPanel"/>
...
<p:outputPanel id="outerPanel">
<p:outputPanel id="panel1" rendered="#{denemeView.str=='1'}">
<h:outputText value="Output: * " />
<p:inputText id="out" value="#{denemeView.islem}" />
</p:outputPanel>
<p:outputPanel id="panel2" rendered="#{denemeView.str=='2'}">
<h:outputText value="True choice! " />
</p:outputPanel>
</p:outputPanel>
See here for a similar problem.

Checkbox won't update rendered value in table

So heres the skinny of it. I have a rendered tag on my selectOneMenu. I've tried it in various ways, this last one updating the form in the boolean checkbox with the "#form". I am all out of ideas, been working on it for a few days. What am I missing so I can render/unrender based on the selection of the checkbox? Thanks.
<rich:dataTable id="catalogview" width="100%" style="width: 100% !important"
columnClasses="lcolumnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog,columnCatalog"
value="#{pcnAlerts.notifications}" var="pcn" rows="20"
headerClass="headerCatalog" styleClass="table1" footerClass="footer_td" >
<h:column>
<h:selectBooleanCheckbox value="#{pcn.checked}" update="#form" >
<f:ajax listener="#{pcnAlerts.selectItem}" render=":popupForm:popupPanelContents" />
</h:selectBooleanCheckbox>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Status" />
</f:facet>
<h:outputText value="#{pcn.status}" />
<h:selectOneMenu id="StatusMenu" value="#{pcnAlerts.newStatus}" rendered="#{pcn.checked}">
<a4j:ajax update="StatusMenu" listener="#{pcnAlerts.saveStatus()}" />
<f:selectItem itemValue="" itemLabel="New" />
<f:selectItem itemValue="Pending" itemLabel="Pending" />
<f:selectItem itemValue="Complete" itemLabel="Complete" />
<f:selectItem itemValue="Archive" itemLabel="Archive" />
<f:selectItem itemValue="Disregard" itemLabel="Disregard" />
</h:selectOneMenu>
</h:column>
</rich:dataTable>
You must also update catalogview in order to render the components inside the table. Also, make sure your <rich:dataTable> is inside a <h:form>:
<h:form id="frmCatalog">
<rich:dataTable id="catalogview" value="#{pcnAlerts.notifications}" var="pcn">
<h:column>
<h:selectBooleanCheckbox value="#{pcn.checked}">
<f:ajax listener="#{pcnAlerts.selectItem}"
render=":popupForm:popupPanelContents :frmCatalog:catalogview" />
</h:selectBooleanCheckbox>
</h:column>
</rich:dataTable>
</h:form>

Resources