托管bean中的两个托管属性,第二个始终为NULL

时间:2011-06-27 12:38:02

标签: java jsf

我必须将2个属性传递给托管bean,但问题是只传递第一个属性,第二个属性始终为NULL 这是我的托管bean:

<managed-bean>
<managed-bean-name>TestAjax</managed-bean-name> 
<managed-bean-class>DAOKPI.TestAjax</managed-bean-class> 
<managed-bean-scope>request</managed-bean-scope>

  <managed-property>
   <property-name>myChoice</property-name>
   <property-class>java.lang.String</property-class>
   <value>#{ToolsKPI.myChoice}</value>
   </managed-property>

    <managed-property>
   <property-name>myChoiceStatus</property-name>
   <property-class>java.lang.String</property-class>
   <value>#{ToolsJIRA.myChoiceStatus}</value>
</managed-property>

JSF

<h:selectOneMenu value="#{ToolsJIRA.myChoiceStatus}">
              <f:selectItems value="#{ToolsJIRA.getMyListstatus()}" />
 </h:selectOneMenu> 
<p:commandButton ajax="false" action="#{TestAjax.dovalid()}" value="test"</p:commandButton>

ToolsJIRA.java

public class ToolsJIRA implements Serializable{
 private String myChoiceStatus;
 private List<SelectItem> MyListStatus;  
//getters and setters

public List<SelectItem> getMyListstatus()  {
fingSingleStatus fstatus =new fingSingleStatus();
 if (MyListStatus == null) {
  MyListStatus = new ArrayList<SelectItem>();
  for (String val : fstatus.FindListStatus()) {
     MyListStatus.add(new SelectItem(val));
    }
  }
  return MyListStatus;
}

TestAjax.java

public class TestAjax implements Serializable{
private String myChoiceStatus;
  //getters and setters

public String dovalid()
 {  
 System.out.println("status------"+this.getMyChoiceStatus());  ***///here is the   problem always NULL***
 for(int i=0;i<checkbox.length;i++)
  {
    if (checkbox[i].equals("1"))
    {
        System.out.println("priority checked");
        return "Result.xhtml";

    }
    if (checkbox[i].equals("2"))
    {
        System.out.println("project checked");
        return "Test1.xhtml";
    }

 }
  return "index.xhtml";

}

注意:我在另一个bean中尝试过myChoiceStatus并返回一个值!!

0 个答案:

没有答案