My test application contains two h:inputText
and one a4j:outputPanel
which is a trigger for rerendering both text fields. Both text fields are empty at the beginning and the second one is also invisible. After clicking the panel a method is called which sets both input values and also the boolean value for displaying the second text field. Here is the code:
<?xml version="1.0" encoding="UTF-8"?>
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:fm30x="http://myfaces.inter-forum.de/fm30x/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<h:outputStylesheet name="stylesheet.css" library="css" />
</h:head>
<h:body>
<h:form id="mainForm">
<h:panelGrid>
<h:inputText id="text" value="#{testBean.testString}"/>
<h:inputText id="text2" value="#{testBean.trackingId}" rendered="#{testBean.showString}"/>
<a4j:outputPanel layout="block" styleClass="quote" onmousedown="begin();">
<h:outputText value="Thats a test" ></h:outputText>
</a4j:outputPanel>
</h:panelGrid>
<a4j:jsFunction name="begin" actionListener="#{testBean.start}" render="text text2" />
</h:form>
</h:body>
</html>
The problem is that when clicking on the panel only the first text field gets rendered and the second one is still invisible, although I have updated the boolean value in the ajax method inside the bean. It is also strange, that when I always return true for the showString
value in the getter, the second text field value gets updated (I can see it this time because the second text field will be always rendered then). So all in all I can say that the updating of the actual values are correct but the render
attribute of the h:inputText
is not correctly evaluated by ajax. What am I doing wrong?