function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Max Friel.ax1251Max Friel.ax1251 

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. 

Best Answer chosen by Admin (Salesforce Developers) 
SamuelDeRyckeSamuelDeRycke

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

Max Friel.ax1251Max Friel.ax1251

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...

<apex:commandLink action="{!myNew}" status="status2" immediate="true" rerender="pg" Value="New {!$ObjectType[act].Label}" rendered="{!IF(act != 'Account','true','false')}">
	        	<apex:param name="str" value="{!act}" assignTo="{!tabButton}"/> 
	        </apex:commandLink>

 

SamuelDeRyckeSamuelDeRycke

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.

This was selected as the best answer
Max Friel.ax1251Max Friel.ax1251

Hey just wanted to say thanks for the reply.  It worked perfectly with an outputPanel.