Developed component rerender problem
igorg May 27, 2010 3:48 AMYesterday, I've write test page to new component I've developed. It represents list of week days and allows to select several of days. Value of component is bit mask, storing days selected. In the beginning, I wrote simple page displaying the component check if it is updated when one of the days is clicked. I could see visually that client side was updated and debug mode helped me to see that the value is updated too. After that, I've
wrote more complicated test. It has additional component, 'h:inputText' and managed bean that links between components. It supposed the with a4j:support I can seen that days selections in new component will be updated when value in input changes and value in input will change if if one of the days is clicked. The test, based on livedemo for a4j:outputPanel example, works only in one direction. It updates days component when I change the value of input, but input is not updated when I click one of the days, although value of days component is updated. Can anybody tell me if the problem is in test page or in component definition.
Test page:
<?xml version="1.0" encoding="ISO-8859-1" ?> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <%@ 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"%> <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%> <%@ taglib uri="http://sintecmedia.com/richComponents" prefix="my"%> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Insert title here</title> </head> <body> <f:view> <a4j:outputPanel layout="block"> <a4j:outputPanel id="buttons" layout="block"> <h:form> <my:weekDaysButtons value="#{testWeekDaysBean.days}" > <a4j:support event="onchange" reRender="testValue" /> </my:weekDaysButtons> </h:form> </a4j:outputPanel> <a4j:outputPanel id="testValue" layout="block"> <h:form> <h:inputText value="#{testWeekDaysBean.days}"> <f:validateLength maximum="1"/> <a4j:support event="onkeyup" reRender="buttons" /> </h:inputText> </h:form> </a4j:outputPanel> </a4j:outputPanel> </f:view> </body> </html>
testWeekDaysBean( request scope):
package beans; import com.sintecmedia.components.component.UIWeekDaysButtons; import com.sintecmedia.components.event.DaySelectedEvent; public class WeekDaysButtonsTestBean { private int dayFlags = 3; public int getDays() { return dayFlags; } public void setDays( int dayFlags ) { this.dayFlags = dayFlags; } protected void updateDay( int index, Boolean val ) { if( val ) { setDays( getDays() & ~UIWeekDaysButtons.DAY_MASKS[ index ] ); } else { setDays( getDays() | UIWeekDaysButtons.DAY_MASKS[ index ] ); } } }
Component definition attached
-
src.zip 13.7 KB