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

Change outputText text with button
Here is my page...
<apex:page controller="Lilly_Customer_Manager" id="pg"> <apex:form > <apex:outputText id="outTxt">{!testStr}</apex:outputText> <apex:repeat value="{!$ObjectType.Account.FieldSets.Lilly_Customer_Manage}" var="f"/> <apex:repeat value="{!actFldMap}" var="act"> <apex:pageBlock title="{!$ObjectType[act].label}" > <apex:pageBlockButtons > <apex:commandButton action="{!mySave}" rerender="pg" Value="Save" rendered="{!IF(act == 'Account','true','false')}"/> <apex:commandLink action="{!myNew}" rerender="pg" Value="New {!$ObjectType[act].Label}" rendered="{!IF(act != 'Account','true','false')}"> <!-- <apex:param name="str" value="{!act}" assignTo="{!tabButton}"/> --> </apex:commandLink> </apex:pageBlockButtons> <apex:repeat value="{!tabIdMap[act]}" var="aciId"> <apex:pageBlockSection title="{!aciNameLookup[aciId]}" columns="2" collapsible="true"> <apex:repeat value="{!newFields[aciId]}" var="aci"> <apex:inputField rendered="{!IF(aci['Type__c'] == 'PICKLIST' || aci['Type__c'] == 'MULTIPICKLIST','false','true')}" label="{!aci['Field_Label__c']}" value="{!aci[fldLookup[aci['Type__c']]]}"/> <apex:selectList rendered="{!IF(aci['Type__c'] == 'PICKLIST','true','false')}" label="{!aci['Field_Label__c']}" value="{!plv[aciId + '.' + aci['Field_Name__c']]}" size="1" multiselect="false"> <apex:selectOptions value="{!plvVals[aci['Object_Name__c'] + '.' + aci['Field_Name__c']]}"/> </apex:selectList> <apex:selectList rendered="{!IF(aci['Type__c'] == 'MULTIPICKLIST','true','false')}" label="{!aci['Field_Label__c']}" value="{!plvMS[aciId + '.' + aci['Field_Name__c']]}" size="5" multiselect="true"> <apex:selectOptions value="{!plvVals[aci['Object_Name__c'] + '.' + aci['Field_Name__c']]}"/> </apex:selectList> </apex:repeat> </apex:pageBlockSection> </apex:repeat> </apex:pageBlock> <apex:repeat > </apex:repeat> </apex:repeat> </apex:form> </apex:page>
And here are the button/link methods...
public PageReference mySave(){ //System.debug('Save pressed for ' + tabButton); testStr = 'bye'; return null; } public PageReference myNew(){ System.debug('Save pressed for ' + tabButton); makeNew(tabButton); testStr = 'bye'; return null; }
I initialize the value of testStr to hi and would expect it to be changed to bye when I click the button or the link. Why does it not? I eventually want to do something much more complicated with this, but wanted to get this simple example working first. I know I am missing something simple here, any help would be appreciated.
I'm not sure if rerendering your page works like you expect ( nor do I consider it good practise). I usually put a <apex:outputpanel> around the components I want to rerender and rerender that.
Give that a try.
All Answers
I changed the command link to inlcude immediate="true", which gave me a null pointer exception, which I expected. I then uncommented out the param which got rid of the error but still no change of the outputText. However now I am seeing a log written for the actions and my statement from that code being put in.
Here is the new commandLink...
I'm not sure if rerendering your page works like you expect ( nor do I consider it good practise). I usually put a <apex:outputpanel> around the components I want to rerender and rerender that.
Give that a try.
Hey just wanted to say thanks for the reply. It worked perfectly with an outputPanel.