This is my Sample backing bean.
@ManagedBean
@SessionScoped
public class Sample {
private String dateText;
public Sample(){
dateText = (new Date()).toString();
}
public String updateDate(){
setDateText((new Date()).toString());
return null;
}
public String getDateText() {
return dateText;
}
public void setDateText(String dateText) {
this.dateText = dateText;
}
}
Scenario 01
<h:head></h:head>
<h:body>
<h:form>
<h:inputText id="txtFirst" value="#{sample.dateText}"/>
<h:inputText id="txtSecond" value="#{sample.dateText}"/>
<h:commandButton action="#{sample.updateDate}"/>
</h:form>
</h:body>
Scenario 02
<h:head></h:head>
<h:body>
<h:form>
<h:inputText id="txtFirst" value="#{sample.dateText}"/>
<p:inputText id="txtSecond" value="#{sample.dateText}"/>
<h:commandButton action="#{sample.updateDate}"/>
</h:form>
</h:body>
Scenario 03
<h:head></h:head>
<h:body>
<h:form>
<h:inputText id="txtFirst" value="#{sample.dateText}"/>
<p:inputText id="txtSecond" value="#{sample.dateText}"/>
<p:commandButton action="#{sample.updateDate}"/>
</h:form>
</h:body>
Scenario 04
<h:head></h:head>
<h:body>
<h:form>
<h:inputText id="txtFirst" value="#{sample.dateText}"/>
<p:inputText id="txtSecond" value="#{sample.dateText}"/>
<p:commandButton action="#{sample.updateDate}" update="@form"/>
</h:form>
</h:body>
When I click on the commandButton
,
Scenario 01 : Works fine. I can see new date values from both inputText
fields without manually refreshing the page.
Scenario 02 : It refreshes the page. Cannot see any ajax behavior. New values are there.
Scenario 03 : Nothing happens. No refreshes. No value changes. To see the values I have to refresh the page manually.
Scenario 04 : Works like Scenario 01
Please someone give me a little explanation about what is happening here with these components.
I have used ICEfaces
, but I haven't see anything like this.
Thank you!