You need to sign in to do that
Don't have an account?

The sequence of the apex code and visualforce page ??
Apex code:
public class pgRefnewWindow { String s; public String Str {get;set;} public String getU() { pStr(); return s; } public pageReference pStr() { s = Str; return null; } }
Visualforce Page:
<apex:page controller="pgRefnewWindow" sidebar="false"> <apex:form > <apex:inputText size="36" value="{!Str}"/> <apex:commandButton onClick="alert('{!U}');" value="Alert"/> <apex:commandButton action="{!pStr}" value="Set String"/> </apex:form> </apex:page>
After inputing some text in the form, and click the "Alert", the page always displays null. i.e. It's the previous value of the "inputText".
It's ok to display the input only if click "Set String" and then click "Alert".
Even, adding the pageReference function in the getter. It doesn't work still... so strange...
public String getU() { pStr(); return s; }
Just want to know the sequence of the codes between Apex class and Visualforce.
And, is it a way to display the inputText right away a click after input ?
could you please let me know what the PageReference will do and what your pageReference is doing
The pageReference is an action of the form Button. What it will do is set the value of inputText to variable 's'.
k i got it
you are assigning str to s in the Pstr() and calling that in the getU(), pstr() may be have a value for s but the method is returning null.
Obviously you will get null.
About PageReference it is generally used for navigating from one page to another. Ofcourse your intension may also work.