p:commandButton not working in p:wizard - java

The problem that I am facing is that <p:commandButton> with id="emailav" doesn't call the action method emailAvailability. I am using it inside p:wizard and also I have included the following block of code inside h:form.
1) xhtml
<p:tab id="personal" title="Personal">
<p:panel header="Personal Details" style="font-size:small">
<h:panelGrid columns="3" columnClasses="label, value"
styleClass="grid">
<h:outputText value="Username*" />
<p:inputText id="usrname" required="true" label="Username"
value="#{registrationBean.user.userName}"
requiredMessage="Username required" />
<p:message for="usrname"></p:message>
<h:outputText value="Firstname: *" />
<p:inputText id="frstname" required="true" label="Firstname"
value="#{registrationBean.user.firstName}"
requiredMessage="Firstname required" />
<p:message for="frstname"></p:message>
<h:outputText value="Lastname: *" />
<p:inputText id="lstname" required="true" label="Lastname"
value="#{registrationBean.user.lastName}"
requiredMessage="Lastname required" />
<p:message for="lstname"></p:message>
<h:outputText value="Password: *" />
<p:password id="pwd1" value="#{registrationBean.user.password}"
feedback="true" match="pwd2" label="Password" required="true"
requiredMessage="Password required" />
<p:message for="pwd1"></p:message>
<h:outputText value="Confirm Password: *" />
<p:password id="pwd2" value="#{registrationBean.user.password}"
label="Confirm Password" required="true"
requiredMessage="Enter the password again" />
<p:message for="pwd2"></p:message>
<h:outputText value="Date of Birth(dd/MM/yyyy):" />
<p:inputText id="dob" label="Date of Birth"
value="#{registrationBean.user.birthDate}" />
<p:message for="dob"></p:message>
<h:outputText value="Gender: " />
<p:selectOneMenu id="gender" value="#{registrationBean.user.gender}">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItem itemLabel="Male" itemValue="Male" />
<f:selectItem itemLabel="Female" itemValue="Female" />
<f:selectItem itemLabel="Other" itemValue="Other" />
</p:selectOneMenu>
<p:message for="gender"></p:message>
<h:outputText value="Relationship Status: " />
<p:selectOneMenu id="relationship"
value="#{registrationBean.user.relationship}">
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItem itemLabel="Single" itemValue="Single" />
<f:selectItem itemLabel="Committed" itemValue="Committed" />
<f:selectItem itemLabel="Open relationship" itemValue="Open relationship" />
<f:selectItem itemLabel="Its comlicated" itemValue="Its complicated" />
</p:selectOneMenu>
<p:message for="relationship"></p:message>
<h:outputText value="Email: *" />
<p:inputText id="email" label="Email"
value="#{registrationBean.user.email}" required="true"
requiredMessage="Email required"/>
<p:message for="email"/>
<p:commandButton id="emailav" value="email availability"
action="#{registrationBean.emailAvailability}" update="emailav" />
<p:message for="emailav"></p:message>
<p:commandButton style="display:none"/>
<h:outputText value="Skip to last: " />
<h:selectBooleanCheckbox value="#{registrationBean.skip}" />
</h:panelGrid>
</p:panel>
</p:tab>
2)Backing bean
public String emailAvailability() {
logger.info("inside emailAvailability");
FacesContext context = FacesContext.getCurrentInstance();
Query query = em.createQuery("SELECT u FROM User u", User.class);
List<User> results = query.getResultList();
Iterator<User> it = results.listIterator();
while (it.hasNext()) {
if (it.next().getEmail().equals(user.getEmail())) {
context.addMessage(null,
new FacesMessage("Email already taken"));
}
}
context.addMessage(null, new FacesMessage("Email not taken"));
return "success";
}

try adding process="#this"
like
<p:commandButton
value="Add Site 1"
update="editor"
title="Remover"
action="#{jobEngine2MB.addSiteType1}"
process="#this" />

Related

How I pass values from one JSF to another while both are backed by separate Request scoped managed beans

I have gone through a few answers on this topic already, especially from BalusC blogs. But its somehow not working in the implementation below. Am I missing something or doing something completely wrong.
I have a basic form with a few dropdowns, when I submit the form i.e. call submitDetails it returns the following String "phaseTwo?faces-redirect=true" which is backed by bean called PhaseTwoController.java
So on submit from phaseOne.xhtml I want to see phaseTwo.xhtml with values selected on phaseOne.xhtml
Here is the code:
THis is PhaseOne.xhtml backed by PhaseOneController.java
<h:form>
<p:panel header="Select country" style="margin-bottom:10px;">
<h:panelGrid columns="2" cellpadding="5">
<p:outputLabel for="country" value="Country: " />
<p:selectOneMenu id="country" value="#{phaseOneController.country}" style="width:150px">
<p:ajax listener="#{phaseOneController.onCountryChange}" update="subCategory" />
<f:selectItem itemLabel="Select Country" itemValue="" noSelectionOption="true" />
<f:selectItems value="#{phaseOneController.countries}" />
</p:selectOneMenu>
<p:outputLabel for="province" value="Province: " />
<p:selectOneMenu id="province" value="#{phaseOneController.province}" style="width:150px">
<p:ajax listener="#{phaseOneController.onProvinceChange}" update="city" />
<f:selectItem itemLabel="Select Province" itemValue="" noSelectionOption="true" />
<f:selectItems value="#{phaseOneController.provinces}" />
</p:selectOneMenu>
<p:outputLabel for="city" value="City: " />
<p:selectOneMenu id="city" value="#{phaseOneController.city}" style="width:150px">
<f:selectItem itemLabel="Select City" itemValue="" noSelectionOption="true" />
<f:selectItems value="#{phaseOneController.cities}" />
</p:selectOneMenu>
</h:panelGrid>
<p:separator />
<p:commandButton value="Select" actionListener="#{phaseOneController.submitDetails}" icon="ui-icon-check">
<f:param name="country" value="#{phaseOneController.country}" />
<f:param name="province" value="#{phaseOneController.province}" />
<f:param name="city" value="#{phaseOneController.city}" />
</p:commandButton>
</p:panel>
</h:form>
#ManagedBean
#RequestScoped
public class PhaseTwoController {
#ManagedProperty(value="#{param.country}")
private String country;
#ManagedProperty(value="#{param.province}")
private String province;
public void setCountry(String country) {
this.country = country;
}
public void setProvince(String province) {
this.province = province;
}
public void setCity(String city) {
this.city = city;
}
}
P.S. I havent posted the code for PhaseOneController.java as I am not sure if it is needed. But if someone wants to look at it, I can post it.

Forward variable on the next page

I have a Users table. Added, view and delete work. But I have problem to edit.
My list page:
<h:form id="form">
<p:dataTable styleClass="table" value="#{userMB.allAdmins}" var="admin" paginator="true" rows="15" rowKey="#{admin.id}" selection="#{userMB.user}" selectionMode="single">
<f:facet name="header">
Lista administratorów
</f:facet>
<p:column headerText="#{msg.firstName}">
<h:outputText value="#{admin.firstName}" />
</p:column>
<p:column headerText="#{msg.lastName}">
<h:outputText value="#{admin.lastName}" />
</p:column>
<p:column headerText="#{msg.personalId}">
<h:outputText value="#{admin.personalId}" />
</p:column>
<f:facet name="footer">
<p:commandButton id="viewButton" value="#{msg.info}" icon="ui-icon-search"
update=":form:display" oncomplete="userDialog.show()"/>
<p:commandButton action="#{userMB.createStart()}" value="#{msg.add}" icon="ui-icon-plus" />
<p:commandButton action="#{userMB.editStart()}" value="#{msg.edit}" >
<f:setPropertyActionListener target="#{userMB.user}" value="#{userMB.user}" />
</p:commandButton>
<p:commandButton action="#{userMB.deleteUser()}" value="#{msg.delete}" icon="ui-icon-close"/>
</f:facet>
</p:dataTable>
<p:dialog id="dialog" header="Administrator" widgetVar="userDialog" resizable="false"
width="300" showEffect="clip" hideEffect="explode">
<h:panelGrid id="display" columns="2" cellpadding="4">
<f:facet name="header">
<p:graphicImage value="./../../images/person4.png" width="150" height="150"/>
</f:facet>
<h:outputText value="#{msg.firstName}" />
<h:outputText value="#{userMB.user.firstName}" />
<h:outputText value="#{msg.lastName}" />
<h:outputText value="#{userMB.user.lastName}" />
<h:outputText value="#{msg.personalId}" />
<h:outputText value="#{userMB.user.personalId}" />
</h:panelGrid>
</p:dialog>
</h:form>
I want to send the selected user on the next page:
I use aciontListener:
<p:commandButton action="#{userMB.editStart()}" value="#{msg.edit}" >
<f:setPropertyActionListener target="#{userMB.user}" value="#{userMB.user}" />
</p:commandButton>
My edit page where I want to send user:
<h:form>
<div id="userPanel">
<h:inputHidden value="#{userMB.user}" />
<p:panel id="panelUser" header="Edytuj administratora" >
<div id="panelImage">
<img src="./../../images/person4.png" alt="person" width="150px" height="130px"/>
</div>
<h:panelGrid columns="3">
<p:outputLabel for="firstName" value="#{msg.firstName}"></p:outputLabel>
<p:inputText id="firstName" value="#{userMB.user.firstName}" label="#{msg.firstName}" required="true">
<f:validator validatorId="nameValidator" />
<p:ajax update="msgFristName" event="keyup" />
</p:inputText>
<p:message for="firstName" id="msgFristName"/>
<p:outputLabel for="lastName" value="#{msg.lastName}"></p:outputLabel>
<p:inputText id="lastName" value="#{userMB.user.lastName}" label="#{msg.lastName}" required="true">
<f:validator validatorId="nameValidator" />
<p:ajax update="msgLastName" event="keyup" />
</p:inputText>
<p:message for="lastName" id="msgLastName"/>
<p:outputLabel for="personalId" value="#{msg.personalId}"></p:outputLabel>
<p:inputText id="personalId" value="#{userMB.user.personalId}" label="#{msg.personalId}" required="true">
<f:validator validatorId="personalIdValidator" />
<p:ajax update="msgPersonalId" event="keyup" />
</p:inputText>
<p:message for="personalId" id="msgPersonalId"/>
<p:outputLabel for="password" value="#{msg.password}"></p:outputLabel>
</p:panel>
</div>
</h:form>
I added: <h:inputHidden value="#{userMB.user}" /> but I do not see data user, only empty field. How do I send this person? I used once this method in other project, a little different without primefaces and it worked. Why now does not work?
Method editStart:
public String editStart() {
return "editStart";
}
faces-config:
<navigation-case>
<from-outcome>editStart</from-outcome>
<to-view-id>/protected/admin/adminEdit.xhtml</to-view-id>
<redirect/>
</navigation-case>
When I'm on the side adminEdit I edited the pool and do editUser method:
public String editUser() {
FacesContext context = FacesContext.getCurrentInstance();
Map requestParameterMap = (Map) context.getExternalContext().getRequestParameterMap();
try {
String userRole = requestParameterMap.get("userRole").toString();
String active = requestParameterMap.get("active").toString();
Boolean act = Boolean.parseBoolean(active);
user.setRole(userRole);
user.setActive(act);
userDao.update(user);
} catch (EJBException e) {
sendErrorMessageToUser("Edit error");
return null;
}
sendInfoMessageToUser("Account edited");
return user.getRole() + "List";
}
My method editStart use only for navigation.
You can either consider Przemek's answer or use one of the 4 ways of passing a parameter to a backing bean.
1. Method expression
2. f:param
3. f:atribute
4. f:setPropertyActionListener
For very well explained full explanation refer to this
It has easy to understand examples. Take a look and pick what fits your needs.
Or simply:
In the actual managed bean...
public String navigationButtonListener(User parameter) {
FacesContext.getCurrentInstance().getExternalContext().getRequestMap()
.put("parameterAttribute", parameter);
return "my-destination-page";
}
In the destination managed bean...
#PostConstruct
public void init(){
myAttribute= (User) FacesContext.getCurrentInstance()
.getExternalContext().getRequestMap().get("parameterAttribute");
}
Good Luck!
You can pass your userid through the session.
Add a parameter to your commandLink
<p:commandButton action="#{userMB.editStart()}" value="#{msg.edit}>
<f:param name="userId" value="#{userMB.user.id}" />
</p:commandButton>
In your backing bean do this
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest myRequest = (HttpServletRequest)context.getExternalContext().getRequest();
HttpSession mySession = myRequest.getSession();
Integer userId = Integer.parseInt(myRequest.getParameter("userId"));
After that you can reload the user you want to edit with the Id you got

How to update jsf datatable from back bean

I have a form that user should enter some values to get some info from a web service. Firstly user fulfills the form and then as he clicks the request button webservice is called. Until here everything works nicely. But as the webservice returns the info, I have to re-render the datatable with the new data. Here is my page:
<h:body>
<h:form id="formCus">
<h:outputLabel value="Müşteri Tipi: *"/>
<p:selectOneMenu id="customerType" value="#{customerService.musteriTipi}" style="width: 39%">
<f:selectItem itemLabel="" itemValue=" " />
<f:selectItem itemLabel="Bireysel" itemValue="BIREYSEL" />
<f:selectItem itemLabel="Tüzel" itemValue="TUZEL" />
<f:selectItem itemLabel="Yabancı" itemValue="YABANCI" />
<p:ajax event="change" update="#{customerService.musteriTipi}"/>
</p:selectOneMenu>
<h:outputLabel value="Ad/Firma Adı: *" for="customerName" />
<p:inputText id="customerName" value="#{customerService.adFirmaAdi}" title="Müşteri adı." >
<p:ajax event="change" update="#{customerService.adFirmaAdi}" />
</p:inputText>
<h:outputLabel value="Soyad/Ünvan: *" for="customerSurname" />
<p:inputText id="customerSurname" value="#{customerService.soyadUnvan}" title="Müşteriye ait soyad/ünvan." >
<p:ajax event="change" update="#{customerService.soyadUnvan}" />
</p:inputText>
<h:outputLabel value="TC Kimlik No: *" />
<p:inputText id="customerTC" value="#{customerService.tcKimlikNo}" title="TC Kimlik numarasını buraya girin.TC numarası sadece sayılardan oluşmalıdır." >
<p:ajax event="change" update="#{customerService.tcKimlikNo}" partialSubmit="true" process="#this"/>
</p:inputText>
<h:outputLabel value="Vergi No:" />
<p:inputText id="customerVergi" value="#{customerService.vergiNo}" title="TC Kimlik numarasını buraya girin.TC numarası sadece sayılardan oluşmalıdır." >
<p:ajax event="change" update="#{customerService.vergiNo}" partialSubmit="true"/>
</p:inputText>
<h:outputLabel value="Müdürlük Kodu: *" />
<p:inputText id="departmantId" value="#{customerService.mudurlukKodu}" title="Müdürlük kodunu buraya girin.Müdürlük kodu sadece sayılardan oluşmalıdır." >
<p:ajax event="change" update="#{customerService.mudurlukKodu}" partialSubmit="true"/>
</p:inputText>
<h:outputLabel value="Müşteri Kodu: " />
<p:inputText id="customerId" value="#{customerService.musteriKodu}" title="Müdürlük kodunu buraya girin.Müdürlük kodu sadece sayılardan oluşmalıdır." >
<p:ajax event="change" update="#{customerService.musteriKodu}" />
</p:inputText>
<h:outputLabel value="E-Posta Adresi: " />
<p:inputText id="customerMail" value="#{customerService.mail}" title="Müşteriye ait e-mail adresini buraya girin." >
<p:ajax event="change" update="#{customerService.mail}" partialSubmit="true"/>
</p:inputText>
<h:outputText value=" "/>
<p:commandButton id="query" value="Müşteri Sorgula" actionListener="#{customerService.request}" async="true" onsuccess="panelwv.show()">
<f:ajax execute="#form" render=":personList" ></f:ajax>
</p:commandButton>
</h:form>
<h:panelGrid columns="5">
<h:outputText value=""/>
<h:outputText value=""/>
<p:panel widgetVar="panelwv" visible="false" closable="true" header="Sorgu Yapılıyor...">
<p:graphicImage value="/resources/images/ajaxloadingbar.gif" />
</p:panel>
<h:outputText value=""/>
<h:outputText value=""/>
</h:panelGrid>
<h:outputText value="Bulunan Müşterilere Ait Bilgiler:" />
<h:form id="personList" rendered="#{not empty customerService.musteriKodu}">
<p:dataTable value="#{customerService.customer}" var="item" id="persontable" emptyMessage="Henüz müşteri eklemediniz.">
<p:column headerText="Müşteri/Firma ID">
#{item.customerId}
</p:column>
<p:column headerText="Ad/Firma Adı">
#{item.customerName}
</p:column>
<p:column headerText="Soyad/Ünvan" >
#{item.customerSurname}
</p:column>
<p:column headerText="Müşteri Tipi" >
#{item.customerType}
</p:column>
<p:column headerText="Telefon" >
#{item.customerTel}
</p:column>
<p:column headerText="Adres">
#{item.customerAddress}
</p:column>
<p:column headerText="E-Posta">
#{item.customerMail}
</p:column>
</p:dataTable>
</h:form>
</h:body>
And here is my back bean:
//some getter and setters
List<Customers> customer = new ArrayList<Customers>();
public List<Customers> getCustomer() {
return customer;
}
public void setCustomer(List<Customers> customer) {
this.customer = customer;
}
public String request() {
final RequestContext context = RequestContext.getCurrentInstance();
//System.out.println("Progress...");
//musteriSorgula(musteriSorgulaKriter());
new Thread(new Runnable() {
public void run() {
try {
musteriKodu = String.valueOf(musteriSorgula(musteriSorgulaKriter()).getMusteriBilgisi().getMusteriKodu());
List<TelefonBilgisi> tel_result = telefonSorgula(telefonSorgulaKriter(musteriKodu)).getMusteriTelefonListesi();
//telefon = tel_result.getMusteriTelefonListesi().get(0).getTelefonNo();
if (tel_result.size() > 0) {
for (TelefonBilgisi t : tel_result) {
telefon = t.getTelefonNo();
}
} else {
telefon = "No telephone.";
}
List<UavtAdresBilgisi> uavt_result = uavtAdresSorgula(uavtAdresSorgulaKriter(musteriKodu)).getMusteriUavtAdresListesi();
if (uavt_result.size() > 0) {
for (UavtAdresBilgisi u : uavt_result) {
adres = String.valueOf(u.getSehir()) + ", " + String.valueOf(u.getBucak()) + ", " + String.valueOf(u.getKasaba());
}
} else {
adres = "No address.";
}
Customers cust = new Customers(musteriTipi, BigInteger.valueOf(Long.valueOf(musteriKodu)), adFirmaAdi, soyadUnvan, telefon, adres, mail, projectId);
if (!customer.contains(cust)) {
customer.add(cust);
System.out.println("Customer has been added.");
} else {
System.out.println("Customer is still in the list.");
}
} catch (Exception ex) {
Logger.getLogger(CustomerService.class.getName()).log(Level.SEVERE, null, ex);
context.execute("alert('Try again.')");
}
}
}).start();
context.execute("panelwv.close()");
return "";
}
The back bean could connect to webservice and gether the info, I can see that in the logs. In the beginning my datatable is empty. What I want is to show the new data as the webservice responses. context.update("personList") doesn't work when I place it below:
customer.add(cust);
If someone could help me I would be greatly appriciated.
<f:ajax execute="#form" render=":personList" ></f:ajax>
Make a change as
<f:ajax execute="#form" update="persontable" render=":personList" ></f:ajax>
Ok so what you want to do is to force the client to update the data table from your server. Take a look at comet and push technology and also (if you don't need to support older browsers) WebSocket.
If you google around you'll find tutorials on how to do it using JSF. And as you are using Primefaces, not that this library has comet support: checkout p:push and atmosphere support.
This problem is easy to solve if you use RichFaces
I would prefer using RemoteCommand component as #Ömer said.
Try use it at the end of the thread(inside the thread braces) with context.execute("updater();");

Primefaces populate other columns values based on selection of autocomplete

I am using Primefaces AutoComplete and I am getting records from database using Hibernate.
I am able to select values from database when I type in text. What I would like to achieve is when I select a name when I type characters, I would want my other columns in jsf page to get populated. E.g When I select employee name "SMITH" I want employee number, department to get filled with SMITH's employee number and department.
I have the following in jsf page.
<p:autoComplete value="#{myMB.selectedEmployee}"
id="basicPojo" minQueryLength="3"
completeMethod="#{myMB.complete}" var="p"
itemLabel="#{p.empName}"
converter="#{myconverter}"
forceSelection="true" >
<h:outputLabel value="Emp Number" />
<h:outputText value="#{p.employeeNumber}" />
<h:outputLabel value="Department" />
<h:outputText value="#{p.employeeDepartment}" />
</p:autoComplete>
When I select a name, other fields are not getting displayed.
What could be the reason for this? How can I achieve the desired result?
Any help is highly appreciated.
Edit 1
<p:dialog header="Create New Request" style="font-weight:bold"
widgetVar="requestNewDialog" resizable="false"
id="newDlg"
showEffect="fade" hideEffect="fade" appendToBody="true"
modal="true" position="center top" width="850" height="450">
<h:panelGrid columns="2" cellspacing="2">
<h:outputText value="New Employee No:" />
<h:outputText value="" />
</h:panelGrid>
<p:separator />
<p:panelGrid columns="6">
<h:outputLabel value="Employee # " for="emp" />
<p:autoComplete value="#
{myMB.selectedEmployee}"
id="basicPojo" minQueryLength="3"
completeMethod="#{myMB.complete}" var="p"
itemLabel="#{p.longName}"
converter="#{employeeNameConverter}"
forceSelection="true" >
<p:ajax event="itemSelect" update="num"
listener="#{myMB.handleSelect}" />
<h:outputLabel value="Name" for="name" />
<h:outputText value="#{p.employeeNumber}" />
</p:autoComplete>
<h:outputLabel id="num" value="Department" for="dept" />
<p:inputText id="dept" value="#{p.employeeNumber}" >
</p:inputText>
</p:panelGrid>
<p:separator />
</p:dialog>
ManagedBean complete Method
public List<Employee> complete(String query) {
List<Employee> suggestions;
suggestions = new ArrayList<Employee>();
try {
EmployeeQueryData q = new EmployeeQueryData ();
getService().getEmployee(q,query);
employee = q.getResult();
for (Employee p : employee) {
if (p.getEmpName().toLowerCase().contains(query));
suggestions.add(p); //
}
} catch (Exception e) {
}
return suggestions;
}
Use <p:ajax event="itemSelect"...
<p:autoComplete>...
<p:ajax event="itemSelect" update="someOtherFieldId someOtherFieldId2" />
</p:autoComplete>

calling a javascript function everytime a facelets component is loaded

I have created a custom facelets component and I need to set some value to the component everytime it loads based on the value it gets from the bean. I used window.onload function in the component and it works correctly when there is only one of this component in the page. But when I use to or more of this component in my page, only the first component gets its value set. I need a nice way to overcome this problem.
My xhtml is like this
<ui:composition>
<f:subview id="#{id}">
<div id="script" style="display: none;">
<script type="text/javascript">
//<![CDATA[
window.onload = function() {
//this function manipulates the value from the bean
};
function processNepCal(){
//this function is for processing the changed values
}
// ]]>
</script>
</div>
<rich:calendar datePattern="yyyy-MM-d" id="gregCal"
rendered="#{backingBean.dataSetParam.userSession.nepDate }"
value="#{value}" inputClass="#{empty styleClass ? '' : styleClass}" />
<h:panelGroup
rendered="#{!backingBean.dataSetParam.userSession.nepDate}">
<h:panelGrid columns="3">
<rich:comboBox id="nepCalYear" styleClass="datecls"
defaultLabel="year" onchange="processNepCal()" width="53px"
readonly="true" directInputSuggestions="true">
<f:selectItem itemLabel="2067" itemValue="2067" />
<f:selectItem itemLabel="2068" itemValue="2068" />
<f:selectItem itemLabel="2069" itemValue="2069" />
<f:selectItem itemLabel="2070" itemValue="2070" />
</rich:comboBox>
<rich:comboBox id="nepCalMonth" styleClass="datecls"
onchange="processNepCal()" width="65px" readonly="true"
defaultLabel="month" directInputSuggestions="true">
<f:selectItem itemLabel="Baisakh" itemValue="Baisakh" />
<f:selectItem itemLabel="Jestha" itemValue="Jestha" />
<f:selectItem itemLabel="Ashad" itemValue="Ashad" />
<f:selectItem itemLabel="Shrawan" itemValue="Shrawan" />
<f:selectItem itemLabel="Bhadra" itemValue="Bhadra" />
<f:selectItem itemLabel="Ahswin" itemValue="Ahswin" />
<f:selectItem itemLabel="Kartik" itemValue="Kartik" />
<f:selectItem itemLabel="Mangsir" itemValue="Mangsir" />
<f:selectItem itemLabel="Paush" itemValue="Paush" />
<f:selectItem itemLabel="Magh" itemValue="Magh" />
<f:selectItem itemLabel="Falgun" itemValue="Falgun" />
<f:selectItem itemLabel="Chaitra" itemValue="Chaitra" />
</rich:comboBox>
<rich:comboBox id="nepCalDay" styleClass="datecls"
onchange="processNepCal()" width="43px" readonly="true"
defaultLabel="day" directInputSuggestions="true">
<f:selectItem itemLabel="01" itemValue="01" />
<f:selectItem itemLabel="02" itemValue="02" />
<f:selectItem itemLabel="03" itemValue="03" />
<f:selectItem itemLabel="04" itemValue="04" />
<f:selectItem itemLabel="05" itemValue="05" />
<f:selectItem itemLabel="06" itemValue="06" />
<f:selectItem itemLabel="07" itemValue="07" />
<f:selectItem itemLabel="08" itemValue="08" />
<f:selectItem itemLabel="09" itemValue="09" />
<f:selectItem itemLabel="10" itemValue="10" />
<f:selectItem itemLabel="11" itemValue="11" />
<f:selectItem itemLabel="12" itemValue="12" />
<f:selectItem itemLabel="13" itemValue="13" />
<f:selectItem itemLabel="14" itemValue="14" />
<f:selectItem itemLabel="15" itemValue="15" />
<f:selectItem itemLabel="16" itemValue="16" />
<f:selectItem itemLabel="17" itemValue="17" />
<f:selectItem itemLabel="18" itemValue="18" />
<f:selectItem itemLabel="19" itemValue="19" />
<f:selectItem itemLabel="20" itemValue="20" />
<f:selectItem itemLabel="21" itemValue="21" />
<f:selectItem itemLabel="22" itemValue="22" />
<f:selectItem itemLabel="23" itemValue="23" />
<f:selectItem itemLabel="24" itemValue="24" />
<f:selectItem itemLabel="25" itemValue="25" />
<f:selectItem itemLabel="26" itemValue="26" />
<f:selectItem itemLabel="27" itemValue="27" />
<f:selectItem itemLabel="28" itemValue="28" />
<f:selectItem itemLabel="29" itemValue="29" />
<f:selectItem itemLabel="30" itemValue="30" />
<f:selectItem itemLabel="31" itemValue="31" />
<f:selectItem itemLabel="32" itemValue="32" />
</rich:comboBox>
</h:panelGrid>
<h:inputText id="nepCalVal" value="#{value}"
styleClass="#{empty styleClass ? '': styleClass}"
style="display:none;">
<f:converter converterId="NepaliDateConverter"></f:converter>
</h:inputText>
</h:panelGroup>
</f:subview>
</ui:composition>
First of all, why don't you just use the component's value attribute for this?
<x:someComponent value="#{bean.value}" />
Do if necessary the manipulation just straight in the bean or with help of a fullworthy Converter.
As to your concrete problem, everytime you declare a window.onload = function() {} the previously declared one will be overridden. The window can has only one onload function. You basically need to put them all in the same onload function.
Better is to use element.addEventListener instead. Here's a crossbrowsercompatible snippet:
function addEvent(element, event, func) {
if (element.addEventListener) {
element.addEventListener(event, func, false); // Real browsers.
return true;
} else if (element.attachEvent) {
return element.attachEvent("on" + event, func); // MSIE<=8.
} else {
return false; // Really ancient browsers.
}
}
So that you can use
addEvent(window, "load", function() {
// Do here your thing.
});

Categories

Resources