-
1. rich:select not modifying bean value
msansm1 May 11, 2011 8:09 AM (in response to msansm1)with this it will be better...
<rich:select value="#{authentication.lang}">
<f:selectItem itemValue="en" itemLabel="English"></f:selectItem>
<f:selectItem itemValue="fr" itemLabel="Francais"></f:selectItem>
</rich:select>
<a4j:commandButton action="#{authentication.updateLocale}" value="change">
</a4j:commandButton>
This is the code I use and which don't work.
-
2. rich:select not modifying bean value
iabughosh May 11, 2011 8:25 AM (in response to msansm1)i think you are missing h:form surronding the rich:select & a4j:commandButton.
-
3. rich:select not modifying bean value
msansm1 May 11, 2011 8:36 AM (in response to iabughosh)I have the h:form, it surrounds a table where my rich:select is.
I still try with another just surrounding this part of code, but it doesn't work at all...
-
4. Re: rich:select not modifying bean value
iabughosh May 11, 2011 9:19 AM (in response to msansm1)try adding this to your rich:select
<a4j:ajax event="selectitem" execute="@this"/>
if that doesn't help please post your xhtml file.
for more info what is your bean scope ?.
-
5. Re: rich:select not modifying bean value
msansm1 May 11, 2011 10:42 AM (in response to iabughosh)I tried, but unsuccessfull...
The bean has a session scope.
I post the complete h:form
<h:form>
<table cellspacing="0" cellpadding="0" style="width: 100%; border-width: 0px">
<tr style="border-width: 0px">
<td rowspan="4" width="30%" style="border-width: 0px"><center><h:graphicImage url="/img/logo_devoteam.png" border="0" ></h:graphicImage></center></td>
<td rowspan="4" width="30%" style="border-width: 0px"><center><h:graphicImage url="/img/logoARM.png" width="223" height="100" border="0" ></h:graphicImage></center></td>
<td rowspan="4" width="30%" style="border-width: 0px"><center><h:graphicImage url="/img/logo_devoteam.png" border="0" ></h:graphicImage></center></td>
<td rowspan="4" width="10%" style="border-width: 0px">
<rich:panel style="float:right;height:90px;width:110px;border-style:ridge;border-color:#D6D6E2;">
<h:outputLabel value="#{messages['head.welcome']}"></h:outputLabel><br/>
<rich:popupPanel modal="" id="panel" width="450" height="580">
<f:view locale="#{authentication.lang}">
<f:facet name="header">
<h:panelGroup>
<h:outputText value="#{messages['myprofile.title']}"></h:outputText>
</h:panelGroup>
</f:facet>
<f:facet name="controls">
<h:panelGroup>
<h:graphicImage value="/img/l_cancel.gif" onclick="#{rich:component('panel')}.hide(); return false;" >
</h:graphicImage>
</h:panelGroup>
</f:facet>
<table width="100%">
<tr>
<td><h:outputText value="#{messages['myprofile.changePass']}" style="font-weight:bold;"></h:outputText></td>
</tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.oldPass']}" ></h:outputLabel></td>
<td><h:inputSecret onmousemove="this.style.backgroundColor= #DEF654 " onmouseout="this.style.backgroundColor= #ffffff " size="20"></h:inputSecret></td>
</tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.newPass']}" ></h:outputLabel></td>
<td><h:inputSecret onmousemove="this.style.backgroundColor= #DEF654 " onmouseout="this.style.backgroundColor= #ffffff " size="20"></h:inputSecret></td>
</tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.confirmPass']}" ></h:outputLabel></td>
<td><h:inputSecret onmousemove="this.style.backgroundColor= #DEF654 " onmouseout="this.style.backgroundColor= #ffffff " size="20"></h:inputSecret></td>
</tr>
<tr><td><br/></td></tr>
<tr>
<td><h:outputText value="#{messages['myprofile.changeData']}" style="font-weight:bold;"></h:outputText></td>
</tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.firstName']}" ></h:outputLabel></td>
<td><h:inputText value="#{authentication.firstName}" onmousemove="this.style.backgroundColor= #DEF654 " onmouseout="this.style.backgroundColor= #ffffff " size="20" ></h:inputText></td>
</tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.lastName']}" ></h:outputLabel></td>
<td><h:inputText value="#{authentication.lastName}" onmousemove="this.style.backgroundColor= #DEF654 " onmouseout="this.style.backgroundColor= #ffffff " size="20"></h:inputText></td>
</tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.mail']}" ></h:outputLabel></td>
<td><h:inputText onmousemove="this.style.backgroundColor= #DEF654 " onmouseout="this.style.backgroundColor= #ffffff " size="20"></h:inputText></td>
</tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.company']}" ></h:outputLabel></td>
<td><h:inputText onmousemove="this.style.backgroundColor= #DEF654 " onmouseout="this.style.backgroundColor= #ffffff " size="20"></h:inputText></td>
</tr>
<tr><td><br/></td></tr>
<tr>
<td><h:outputText value="#{messages['myprofile.changeMails']}" style="font-weight:bold;"></h:outputText></td>
</tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.actionMail']}" ></h:outputLabel></td>
<td><h:selectBooleanCheckbox ></h:selectBooleanCheckbox></td>
</tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.dailyMail']}" ></h:outputLabel></td>
<td><h:selectBooleanCheckbox ></h:selectBooleanCheckbox></td>
</tr>
<tr><td><br/></td></tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.changeLang']}" style="font-weight:bold;"></h:outputLabel></td>
<td><rich:select value="#{authentication.lang}">
<f:selectItem itemValue="en" itemLabel="English"></f:selectItem>
<f:selectItem itemValue="fr" itemLabel="Francais"></f:selectItem>
<a4j:ajax event="selectitem" execute="@this"/>
</rich:select>
<a4j:commandButton action="#{authentication.updateLocale}" value="change">
</a4j:commandButton>
</td>
</tr>
<tr><td><br/></td></tr>
<tr>
<td><h:outputText value="#{messages['myprofile.changeSkin']}" style="font-weight:bold;"></h:outputText></td>
</tr>
<tr>
<td>
<ul id="skin-menu" class="layout">
<a4j:repeat var="skin" value="#{skinBean.skins}"
iterationStatusVar="iterStatus">
<li class="#{(skin==skinBean.skin) ? 'current-skin' : ''}">
<h:link includeViewParams="true">
<a4j:outputPanel>#{skin}</a4j:outputPanel>
<f:param name="skin" value="#{skin}" />
</h:link>
</li>
</a4j:repeat>
</ul>
</td>
</tr>
</table>
<br/>
<center>
<h:outputLink value="#" onclick="#{rich:component('panel')}.hide()">
<h:outputLabel value="#{messages['myprofile.close']}"></h:outputLabel>
</h:outputLink>
</center>
</f:view>
</rich:popupPanel>
<h:outputLink value="#" id="link" onclick="#{rich:component('panel')}.show()">
<h:outputLabel value="#{authentication.firstName}"></h:outputLabel><br/>
<h:outputLabel value="#{authentication.lastName}"></h:outputLabel>
</h:outputLink>
<br/><br/>
<h:outputLabel value="#{messages['head.logout']}"></h:outputLabel>
</rich:panel>
</td>
</tr>
</table>
</h:form>
If hope it will help...
-
6. Re: rich:select not modifying bean value
iabughosh May 11, 2011 5:16 PM (in response to msansm1)try <a4j:ajax event="change" execute="@this"/> it works with me.
regards.
-
7. Re: rich:select not modifying bean value
msansm1 May 12, 2011 4:43 AM (in response to iabughosh)I tried, but it doesn't work...
I will put more of my code, if you don't see anything wrong, can you give me your test ?
------------------------------------------------------------------------------------------
MAIN.XHTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8"/>
<title><h:outputText value="#{messages['application.title']}"/></title>
<h:outputStylesheet library="css" name="styles-default.css"/>
</head>
<body id="entirePage">
<f:view locale="#{authentication.lang}">
<ui:include src="/templates/includes/header.xhtml" />
<br/>
<br/>
<div id="projectList">
<ui:include src="/templates/projects.xhtml" />
<br/>
</div>
</f:view>
</body>
</html>
----------------------------------------------------------------------------------------------
HEADER.XHTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<f:view contentType="text/html">
<h:head>
<title><h:outputText value="#{messages['application.title']}"/></title>
<h:outputStylesheet library="css" name="StyleCSS.css"/>
</h:head>
<h:body style="width: 100%">
<h:form>
<table cellspacing="0" cellpadding="0" style="width: 100%; border-width: 0px">
<tr style="border-width: 0px">
<td rowspan="4" width="30%" style="border-width: 0px"><center><h:graphicImage url="/img/logo_devoteam.png" border="0" ></h:graphicImage></center></td>
<td rowspan="4" width="30%" style="border-width: 0px"><center><h:graphicImage url="/img/logoARM.png" width="223" height="100" border="0" ></h:graphicImage></center></td>
<td rowspan="4" width="30%" style="border-width: 0px"><center><h:graphicImage url="/img/logo_devoteam.png" border="0" ></h:graphicImage></center></td>
<td rowspan="4" width="10%" style="border-width: 0px">
<rich:panel style="float:right;height:90px;width:110px;border-style:ridge;border-color:#D6D6E2;">
<h:outputLabel value="#{messages['head.welcome']}"></h:outputLabel><br/>
<rich:popupPanel modal="true" id="panel" width="450" height="580">
<f:view locale="#{authentication.lang}">
<f:facet name="header">
<h:panelGroup>
<h:outputText value="#{messages['myprofile.title']}"></h:outputText>
</h:panelGroup>
</f:facet>
<f:facet name="controls">
<h:panelGroup>
<h:graphicImage value="/img/l_cancel.gif" onclick="#{rich:component('panel')}.hide(); return false;" >
</h:graphicImage>
</h:panelGroup>
</f:facet>
<table width="100%">
<tr>
<td><h:outputText value="#{messages['myprofile.changePass']}" style="font-weight:bold;"></h:outputText></td>
</tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.oldPass']}" ></h:outputLabel></td>
<td><h:inputSecret onmousemove="this.style.backgroundColor= #DEF654 " onmouseout="this.style.backgroundColor= #ffffff " size="20"></h:inputSecret></td>
</tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.newPass']}" ></h:outputLabel></td>
<td><h:inputSecret onmousemove="this.style.backgroundColor= #DEF654 " onmouseout="this.style.backgroundColor= #ffffff " size="20"></h:inputSecret></td>
</tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.confirmPass']}" ></h:outputLabel></td>
<td><h:inputSecret onmousemove="this.style.backgroundColor= #DEF654 " onmouseout="this.style.backgroundColor= #ffffff " size="20"></h:inputSecret></td>
</tr>
<tr><td><br/></td></tr>
<tr>
<td><h:outputText value="#{messages['myprofile.changeData']}" style="font-weight:bold;"></h:outputText></td>
</tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.firstName']}" ></h:outputLabel></td>
<td><h:inputText value="#{authentication.firstName}" onmousemove="this.style.backgroundColor= #DEF654 " onmouseout="this.style.backgroundColor= #ffffff " size="20" ></h:inputText></td>
</tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.lastName']}" ></h:outputLabel></td>
<td><h:inputText value="#{authentication.lastName}" onmousemove="this.style.backgroundColor= #DEF654 " onmouseout="this.style.backgroundColor= #ffffff " size="20"></h:inputText></td>
</tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.mail']}" ></h:outputLabel></td>
<td><h:inputText onmousemove="this.style.backgroundColor= #DEF654 " onmouseout="this.style.backgroundColor= #ffffff " size="20"></h:inputText></td>
</tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.company']}" ></h:outputLabel></td>
<td><h:inputText onmousemove="this.style.backgroundColor= #DEF654 " onmouseout="this.style.backgroundColor= #ffffff " size="20"></h:inputText></td>
</tr>
<tr><td><br/></td></tr>
<tr>
<td><h:outputText value="#{messages['myprofile.changeMails']}" style="font-weight:bold;"></h:outputText></td>
</tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.actionMail']}" ></h:outputLabel></td>
<td><h:selectBooleanCheckbox ></h:selectBooleanCheckbox></td>
</tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.dailyMail']}" ></h:outputLabel></td>
<td><h:selectBooleanCheckbox ></h:selectBooleanCheckbox></td>
</tr>
<tr><td><br/></td></tr>
<tr>
<td><h:outputLabel value="#{messages['myprofile.changeLang']}" style="font-weight:bold;"></h:outputLabel></td>
<td><rich:select value="#{authentication.lang}">
<f:selectItem itemValue="en" itemLabel="English"></f:selectItem>
<f:selectItem itemValue="fr" itemLabel="Francais"></f:selectItem>
<a4j:ajax event="change" execute="@this"/>
</rich:select>
<a4j:commandButton action="#{authentication.updateLocale}" value="change">
</a4j:commandButton>
</td>
</tr>
<tr><td><br/></td></tr>
<tr>
<td><h:outputText value="#{messages['myprofile.changeSkin']}" style="font-weight:bold;"></h:outputText></td>
</tr>
<tr>
<td>
<ul id="skin-menu" class="layout">
<a4j:repeat var="skin" value="#{skinBean.skins}"
iterationStatusVar="iterStatus">
<li class="#{(skin==skinBean.skin) ? 'current-skin' : ''}">
<h:link includeViewParams="true">
<a4j:outputPanel>#{skin}</a4j:outputPanel>
<f:param name="skin" value="#{skin}" />
</h:link>
</li>
</a4j:repeat>
</ul>
</td>
</tr>
</table>
<br/>
<center>
<h:outputLink value="#" onclick="#{rich:component('panel')}.hide()">
<h:outputLabel value="#{messages['myprofile.close']}"></h:outputLabel>
</h:outputLink>
</center>
</f:view>
</rich:popupPanel>
<h:outputLink value="#" id="link" onclick="#{rich:component('panel')}.show()">
<h:outputLabel value="#{authentication.firstName}"></h:outputLabel><br/>
<h:outputLabel value="#{authentication.lastName}"></h:outputLabel>
</h:outputLink>
<br/><br/>
<h:outputLabel value="#{messages['head.logout']}"></h:outputLabel>
</rich:panel>
</td>
</tr>
</table>
</h:form>
<div id="bandeau">
<img src="../img/pixel_transparent.gif" height="4" width="20" />
<h:outputLink value="/template/main.jsf" id="link"><h:outputLabel value="#{messages['main.projects']}"></h:outputLabel></h:outputLink>
</div>
</h:body>
</f:view>
</html>
---------------------------------------------------------------------------------------
FACES-CONFIG (just for bean authentication)
<managed-bean>
<managed-bean-name>authentication</managed-bean-name>
<managed-bean-class>BSM.JSFVersion.Authentication.Authentication</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>_dao</property-name>
<property-class>com.devoteam.armv4.utils.DaoUtil</property-class>
<value/>
</managed-property>
<managed-property>
<property-name>id</property-name>
<property-class>java.lang.String</property-class>
<value/>
</managed-property>
<managed-property>
<property-name>firstName</property-name>
<property-class>java.lang.String</property-class>
<value/>
</managed-property>
<managed-property>
<property-name>lastName</property-name>
<property-class>java.lang.String</property-class>
<value/>
</managed-property>
<managed-property>
<property-name>login</property-name>
<property-class>java.lang.String</property-class>
<value/>
</managed-property>
<managed-property>
<property-name>pass</property-name>
<property-class>java.lang.String</property-class>
<value/>
</managed-property>
<managed-property>
<property-name>lang</property-name>
<property-class>java.lang.String</property-class>
<value/>
</managed-property>
</managed-bean>
----------------------------------------------------------------------------------------
AUTHENTICATION.JAVA
public class Authentication {
private String login;
private String pass;
private String id;
private DaoUtil _dao;
private String lastName;
private String firstName;
private String completeName;
private String lang;
private Locale locale;
public Authentication() {
_dao = new DaoUtil();
}
..........
public String verification() {
System.out.println("Appel Vérification !!!");
String _auth="Non";
HashMap<String, String> map = new HashMap<String, String>();
map.put("log", "Login");
for(TUser user:_dao.getDao().getUserDAO().findAll()){
if (user.getLogin().equals(login)){
if (Crypt.decrypt(user.getPassword()).equals(pass)) {
id=""+user.getId();
firstName=user.getFirstName();
lastName=user.getLastName();
completeName = firstName+" "+lastName;
_auth="Oui";
updateLocale();
break;
}
}
}
System.out.println("Navigation :"+_auth);
return _auth;
}
............
public String getLang() {
return lang;
}
public void setLang(String lang) {
this.lang = lang;
}
public void updateLocale() {
System.out.println("LANGUE :: "+lang);
locale = new Locale(lang);
FacesContext.getCurrentInstance().getViewRoot().setLocale(locale);
FacesContext.getCurrentInstance().getApplication().setDefaultLocale(locale);
}
}
--------------------------------------------------------------------------------
Thanks for your time helping me
-
8. rich:select not modifying bean value
snaker May 12, 2011 7:24 AM (in response to msansm1)Only happens with the select or it happens with other components in the form
Try this:
<h:form>
<a4j:outpupPanel ajaxRendered="true">
...the rest of form
</a4j:outputPanel>
</h:form>
-
9. rich:select not modifying bean value
iabughosh May 13, 2011 4:22 AM (in response to msansm1)i noticed that you are using body instead of h:body in your main page, try using h:body.
-
10. Re: rich:select not modifying bean value
msansm1 May 16, 2011 3:38 AM (in response to msansm1)I have finally found the solution :
<rich:select value="#{authentication.lang}" id="lang">
<f:selectItem itemValue="en" itemLabel="English"></f:selectItem>
<f:selectItem itemValue="fr" itemLabel="Francais"></f:selectItem>
<a4j:ajax event="change" execute="@this"/>
</rich:select>
<a4j:commandButton action="#{authentication.updateLocale}" value="change" reRender="lang">
</a4j:commandButton>
With the reRender, when I refresh the page the langage has changed.
Thanks for all
-
11. Re: rich:select not modifying bean value
locked May 27, 2011 2:47 PM (in response to msansm1)I can't even get rich:select in my list of available components through Netbeans 7.0. Did you have it available for selection, if so which IDE are you using and which JAR files are you using?
I have tried it with RichFaces 4.0 JARS
- richfaces-components-api-4.0.0.Final.jar
- richfaces-components-api-4.0.0.Final-sources.jar
- richfaces-components-ui-4.0.0.Final.jar
- richfaces-components-ui-4.0.0.Final-sources.jar
- richfaces-core-api-4.0.0.Final.jar
- richfaces-core-api-4.0.0.Final-sources.jar
- richfaces-core-impl-4.0.0.Final.jar
- richfaces-core-impl-4.0.0.Final-sources.jar
And what TAG library are you refering to in your page?
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>