form commandButton member variables

I have some get/set methods for which I don't have member variables(Well I have some static strings and I use them to put/get in properties file)

So in my jsp. I have couple of text fields and a button. If I put all the UI components in one form tag, then at runtime it complains that there is no property defined for attr (as in TestBean.attr the actual method will be setAttr, getAttr)

but If put twi form tags one for all the input components and one for the command buttons, it doesn't complain and works as expected.

So I would like to know why the first case failed and second case works fine

This one does n't work

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<f:view>

<html>

<head>

</head>

<body>

<h:form id="x">

<h:panelGrid columns="1">

<h:outputText value="test"/>

</h:panelGrid>

<h:messages />

<h:panelGrid columns="2">

<h:outputText value="Label"/>

<h:inputText value="" />

<h:outputText value="Label2"/>

<h:inputText value="#{TestBean.attr}" />

<h:outputText value="Label3"/>

<h:inputText value="" />

</h:panelGrid>

<h:commandButton value="OK" action="#{TestBean.OKCalled}">

</h:commandButton>

<h:commandButton value="Cancel" action="#{TestBean.cancel}">

</h:commandButton>

</h:form>

</body>

</html>

</f:view>

case 2 This one works

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

<f:view>

<html>

<head>

</head>

<body>

<h:form id="x">

<h:panelGrid columns="1">

<h:outputText value="test"/>

</h:panelGrid>

<h:messages />

<h:panelGrid columns="2">

<h:outputText value="Label"/>

<h:inputText value="" />

<h:outputText value="Label2"/>

<h:inputText value="#{TestBean.attr}" />

<h:outputText value="Label3"/>

<h:inputText value="" />

</h:panelGrid>

</h:form>

<h:form>

<h:commandButton value="OK" action="#{TestBean.OKCalled}">

</h:commandButton>

<h:commandButton value="Cancel" action="#{TestBean.cancel}">

</h:commandButton>

</h:form>

</body>

</html>

</f:view>

publicclass TestBean{

private Hashtable hs =new Hashtable();

publicstatic String NAME ="name";

public TestBean(){

hs.put(NAME,"Joe");

}

public String getAttr(){

return (String)hs.get(NAME);

}

publicvoid setAttr(String y){

System.out.println(y);

}

publicvoid OKCalled(){

System.out.println("called in OKCalled");

}

publicvoid cancel(){

System.out.println("called in Cancel");

}

}

[5133 byte] By [vpalkondaa] at [2007-10-3 0:10:27]
# 1
Never mind its working now again for the first case.
vpalkondaa at 2007-7-14 16:59:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Remove the static identifier.private final String NAME = "name";
BalusCa at 2007-7-14 16:59:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
I need to have static members, because I use them as keys
vpalkondaa at 2007-7-14 16:59:56 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...