2011-07-07 1 views
0

私は同じ豆の中で奇妙なエラーを持っています。同じ祖父を別の豆から2回渡しました。右の値は、常にNULLです。一度正しい値を含む値は別の時間に同じBeanにNULLを含む

<h:selectOneMenu value="#{ToolsKPI.myChoice}"> 
     <f:selectItems value="#{ToolsKPI.getMyListKPI()}" /> 
     <p:ajax event="valueChange" update="f1,f2,f3" 
      listener="#{TestAjax.selectChangeHandler}"></p:ajax> 
</h:selectOneMenu> 

マイ豆:

public class TestAjax implements Serializable{ 
    **private String myChoice**; //getters+seetters 

public void selectChangeHandler() { //in this case myChoice contain the right value 
    form1Visible = false; 
    form2Visible = false; 
    form3Visible = false; 

    if (this.myChoice.equals("Number Of Issues in Status")) 
    { System.out.println("kpi------"+this.myChoice); 
    form1Visible = true; 

    } 
    else if (this.myChoice.equals("Response Time")) 
    form2Visible = true; 
    else if (this.myChoice.equals("Number of Issue between to Status")) 
    form3Visible = true; 
} 





public String CreateQueryNumber() 
{ 
Iterator it= selectedItemscheckbox.iterator(); 
    Iterator it2= selectedItemscheckbox.iterator(); 
     String grouping=""; 
     String selecting=""; 
     String group=""; 


while(it.hasNext()) 
{ 
selecting=selecting +","+it.next().toString(); 
System.out.println("selecting---"+ selecting); 
} 

while(it2.hasNext()) 
{ 
grouping=grouping+it2.next().toString()+","; 
System.out.println("grouping---"+ grouping); 
} 

int endString =grouping.length()-1; 
group= grouping.substring(0,endString) ; 
**System.out.println("choice"+this.getMyChoice()); //in this case it's NULL!!!!!** 

try{ 
    if (myChoice.equals("Number Of Issues in Status")) 
    { 
     System.out.println(myChoice); 

    select ="select count(jiraissue.id) as nb "+selecting; 
    from =" from jiraissue ,priority ,project,issuestatus "; 
    where=" where jiraissue.project=project.id "; 
    jointure=" and jiraissue.issuestatus=issuestatus.id and jiraissue.priority =priority.id and issuestatus.pname="+"'"+this.getMyChoiceStatus()+"' "; 
    groupBy=" group by "+group; 
    sql =select+from+where+jointure+groupBy+" ;"; 

      return sql; 
} 

    if(myChoice.equals("Response Time")) 
    System.out.println(myChoice); 
    { 
    select ="select AVG(jiraissue.id) as nb "+selecting; 
    from =" from jiraissue ,priority ,project,issuestatus "; 
    where=" where jiraissue.project=project.id "; 
    jointure=" and jiraissue.issuestatus=issuestatus.id and jiraissue.priority =priority.id and issuestatus.pname="+"'"+this.getMyChoiceStatus()+"' "; 
    groupBy=" group by "+group; 
    sql =select+from+where+jointure+groupBy+" ;"; 
    System.out.println("sqlKPI2"+sql); 
    return sql; 

} 

}

FacesConfig

<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-bean> 
MY JSF JSF2

を用い I'am

+0

をあなたはmyChoiceフィールドのgetterとsetterが含まれることができますか?あなたがthis.myChoice(フィールド自体)を使用している時間と、それが動作しない時間がthis.getMyChoice()(フィールドのゲッター)を使用している - あなたのゲッターに問題がある可能性があります、あなたはそれを台無しにする方法を私は知らない。 –

+0

@Anthony Grist、私は2回目にthis.myChoiceを試してみましたが、同じ問題が続いています:( – rym

+0

JSF1またはJSF2を使用していますか? – Dejell

答えて

0

このような範囲でビューとしてあなたのBeanを宣言します。

<managed-bean> 
<managed-bean-name>TestAjax</managed-bean-name> 
<managed-bean-class>DAOKPI.TestAjax</managed-bean-class> 
<managed-bean-scope>view</managed-bean-scope> 
    <managed-property> 
    <property-name>myChoice</property-name> 
    <property-class>java.lang.String</property-class> 
    <value>#{ToolsKPI.myChoice}</value> 
</managed-property> 
</managed-bean> 
+0

表示するBeanを変更しました。次のエラーが表示されます。com.sun.faces.mgbean.ManagedBeanPreProcessingException:Erureur Indutendue lors du traitement du beangéreTestAjax – rym

関連する問題