My main problem is: my javascript 'm' variable does not pull the content of 'message' controller property. Please consider the code below. It is a reduced version of my original code:
GrettingPage.page:
<apex:page controller="GrettingController" docType="html-5.0" showHeader="true" sidebar="true">
<script>
function processReturn() {
var m = '{!message}';
alert(m);
}
</script>
<apex:sectionHeader title="composeMessage test" subtitle="Gretting" />
<apex:form>
<apex:pageBlock mode="maindetail">
<apex:messages />
<apex:pageBlockButtons >
<apex:commandButton action="{!composeMessage}" reRender="opResult" oncomplete="processReturn()"/>
</apex:pageBlockButtons>
<apex:pageBlockSection>
<apex:pageBlockSectionItem>
<apex:outputLabel value="Your name" for="uName"></apex:outputLabel>
<apex:inputText value="{!uName}" id="uName" size="20"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:pageBlockSection columns="1">
<apex:pageBlockSectionItem>
<apex:outputPanel id="opResult">
</apex:outputPanel>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
GrettingController.cls:
public with sharing class GrettingController{
public String uName {get;set;}
public String message {get;set;}
public GrettingController() {
}
public PageReference composeMessage() {
message = 'Welcome ' + uName;
system.debug(message);
return null;
}
}
Does anybody have any suggest to solve it?
Thanks in advance.