simple reRender action does not work
norbert45fr Nov 23, 2007 5:09 AMHello all,
That's now couple of days I'm trying to do something that seems quite simple for everyone but it's not working at all. I have read lot of manuals, forum treads, etc but with no success on result.
Description of my problem: I would like to display a value selected in an h:selectOneMenu but nothing is rendered. This is a simple test to try to understand because mi final objective is to hide/show an object base upon selection, but displaying the selection is not working already.
Here is my code:
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<html>
<head>
<title>test</title>
</head>
<body>
<f:view locale="en_US">
<h:form>
<h:messages layout="table"></h:messages>
<h:selectOneMenu id="searchperiod" immediate="true" value="#{solution.selectedPeriod}">
<a4j:support event="onchange" reRender="periodgrid" immediate="true" />
<f:selectItems value="#{solution.periodList}" />
</h:selectOneMenu>
<h:outputText value="value selected: #{solution.selectedPeriod}" id="periodgrid"></h:outputText>
</h:form>
<a4j:log level="DEBUG" popup="false" />
</f:view>
</body>
</html>
package com.test.Beans;
import java.util.ArrayList;
import javax.faces.component.UISelectOne;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
public class Solution {
enum Periods { ALL, LAST_10_DAYS, LAST_30_DAYS, LAST_90_DAYS, LAST_YEAR, CUSTOM };
private String selectedPeriod = null;
private ArrayList<SelectItem> periodList = null;
private String isVisible = "false";
public Solution() {
super();
}
public String getSelectedPeriod() {
return selectedPeriod;
}
public void setSelectedPeriod(String selectItem) {
this.selectedPeriod = selectItem;
}
public ArrayList<SelectItem> getPeriodList() {
if (periodList == null) {
periodList = new ArrayList<SelectItem>();
periodList.add(new SelectItem(Solution.Periods.ALL, "All Time") ) ;
periodList.add(new SelectItem(Solution.Periods.LAST_10_DAYS, "Last 10 days") ) ;
periodList.add(new SelectItem(Solution.Periods.LAST_30_DAYS, "Last 30 days") ) ;
periodList.add(new SelectItem(Solution.Periods.LAST_90_DAYS, "Last 90 days") ) ;
periodList.add(new SelectItem(Solution.Periods.LAST_YEAR, "Last year") ) ;
periodList.add(new SelectItem(Solution.Periods.CUSTOM, "Custom period") ) ;
setIsVisible("false");
}
return periodList;
}
public void setPeriodList(ArrayList<SelectItem> periodList) {
this.periodList = periodList;
}
public String getIsVisible() {
return isVisible;
}
public void setIsVisible(String isVisible) {
this.isVisible = isVisible;
}
}
<?xml version="1.0" encoding="UTF-8"?> <faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd" version="1.2"> <application> <locale-config> <default-locale>en_US</default-locale> <supported-locale>en</supported-locale> </locale-config> </application> <managed-bean> <managed-bean-name> solution</managed-bean-name> <managed-bean-class> com.test.Beans.Solution</managed-bean-class> <managed-bean-scope> session</managed-bean-scope> </managed-bean> </faces-config>
I'm using Eclipse Europa and publish the code to JBoss 4.2.1.GA with Java 1.5_012. I have in lib commons-beanutils-cor. jar, commons-beanutils.jar, commons-beanutils-bean-collections.jar, common-digester-1.8.jar, richfaces-ui-3.1.2.GA.jar, richfaces-api-3.1.2.GA.jar, richfaces-impl-3.1.2.GA.jar, standard.jar, jstl.jar, jsf-impl.jar, jsf-api.jar, phaseTracker.jar and all the JBoss jar
Here is the show/hide I would like to do in final:
<rich:panel header="Search within a period">
<h:panelGrid style="width: 100%; top: auto;">
<h:selectOneMenu id="SearchPeriod" immediate="true" value="#{solution.selectedPeriod}">
<a4j:support event="onchange" reRender="periodgrid" immediate="true" />
<f:selectItems value="#{solution.periodList}" />
</h:selectOneMenu>
<a4j:region>
<a4j:outputPanel id="periodgrid">
<h:panelGrid id="PeriodGrid2" columns="2" style="width: 100%; vertical-align: top;" rendered="#{solution.selectedPeriod} == 'CUSTOM'">
<h:outputText id="FromDateLabel" value="From: " />
<rich:calendar id="FromDate" datePattern="dd-MMM-yyyy" />
<h:outputText id="ToDateLabel" value="To: " />
<rich:calendar id="ToDate" datePattern="dd-MMM-yyyy" />
</h:panelGrid>
</a4j:outputPanel>
</a4j:region>
</h:panelGrid>
</rich:panel>
Does some one can help?
Thanks a lot