I need your help in assigning the entered value in an inputText
to a global variable that can be used in multiple methods in a bean. The JSF page has the code:
<p:dialog id="Dialog1" header="Dialog1" widgetVar="Dialog1">
<p:inputText id="refNo2" value="#{Bean1.refNo}">
<p:ajax event="keyup" update="ref2" />
</p:inputText>
<h:outputText id="ref2" value="#{Bean1.refNo}"/>
<p:commandButton value="Download" ajax="false" actionListener="#{Bean1.PDFExport}" />
</p:dialog>
With the above code anything that is entered in the inputText, it will be shown in the outputText
. And the java code for refNo in Bean1 is:
@SessionScoped
private String refNo = "";
public void setRefNo(String refNo) {
this.refNo = refNo;
}
public String getRefNo() {
return refNo;
}
However, When I am calling PDFExport method in the actionListener, the value of the refNo is blank and therefore I can't write any query because the value of refNo is not passed:
public void PDFExport() {
System.out.println("Reference No. is"+refNo);
}
An example is that if the entered value in the inputText is 99, the outputText will show 99, however on clicking on the commandButton, the refNo value is blank.