Skip to main content

JSF 2.0 GlassFish 3.0.1 problem

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
ilya_40umov
Offline
Joined: 2010-12-27

I'm getting the following problem:
When I rerender the form inside some element and this form was not rendered before h:commandButton and h:commandLink inside this form stop working. I should press a button twice and just then it calls an action from a jsf bean.
Could anyone tell my why commandButton does not work at once after rerendering?
The sample of my code follows below:

xthml page:

<?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:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
<h:head>
<title>test</title>
</h:head>
<h:body>
<a4j:status id="status">
<f:facet name="start">
<h:outputText value="start"/>
</f:facet>
</a4j:status>
<br/>
<br/>
<h:form id="form1">
<h:inputText value="#{testBean.input}"></h:inputText>
<h:commandLink value="Render">
<f:ajax execute="@form" render=":form2Wrapper" event="click"/>
</h:commandLink>
</h:form>
<h:panelGroup id="form2Wrapper">
<h:form id="form2" rendered="#{! empty testBean.input}">
<a4j:commandButton value="Test1_a4j" action="#{testBean.doSomething}"/>
<h:commandButton value="Test1" action="#{testBean.doSomething}"/>
<h:commandLink value="Test2" action="#{testBean.doSomething}"/>
</h:form>
</h:panelGroup>

bean class:
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
* @author sorokoumov
*/
@SessionScoped
@ManagedBean
public class TestBean {

private String input;

public String getInput() {
return input;
}

public void setInput(String input) {
this.input = input;
}

public String doSomething() {
System.out.println("doSomething");
return null;
}
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
ilya_40umov
Offline
Joined: 2010-12-27