I have started learning JSF. I understand from oracle fourm like
when the command button has immediate attribute then all its actions, conversions and validations will happen in ApplyRequestPhase for the button.
When a input has immediate attribute then similarly conversion , validation and all things will be happen in ApplyRequest phase for that input.
But my question is like Both command button and an input text has immediate attribute then can i get the value of input text in the ApplyRequest phase when i click the button?
If it is no then why this behavior for inputs ? If it is yes then that is not working in my sample.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
JSF Immediate Sample
</h:head>
<h:body>
<h:form>
<h:messages globalOnly="true" showDetail="true" showSummary="true"/>
<h:panelGrid border="2" columns="2">
<h:outputText value="Enter Data (Str - Boo)" />
<h:inputText value="#{classicBean.propBoolean}" immediate="true"/>
<h:outputText value="Enter Data" />
<h:inputText value="#{classicBean.propString2}" />
<h:outputText value="Enter Data (Immediate)" />
<h:inputText value="#{classicBean.propString3}" immediate="true"/>
<h:commandButton value="ImmediateButton" action="#{classicBean.testMethod}" immediate="true" />
<h:commandButton value="CommandButton" action="#{classicBean.testMethod}" />
</h:panelGrid>
</h:form>
</h:body>
</html>
public class ClassicManagedBean {
private boolean propBoolean;
private String propString;
private String propString2;
private String propString3;
private String propString4;
private Integer propInteger;
public String testMethod() {
System.out.println("Inside TestMetod......");
System.out.println("Property Boolean :"+propBoolean);
System.out.println("Property String2 :"+propString2);
System.out.println("Property String3 :"+propString3);
return null;
}
}
Log
- Coming to RESTORE_VIEW 1 beforePhase
- Coming to RESTORE_VIEW 1 afterPhase
- Coming to APPLY_REQUEST_VALUES 2 beforePhase
- Inside TestMetod......
- Property Boolean :false
- Property String2 :null
- Property String3 :null
- Coming to APPLY_REQUEST_VALUES 2 afterPhase
- Coming to RENDER_RESPONSE 6 beforePhase
- Coming to RENDER_RESPONSE 6 afterPhase
Thanks Manivannan