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
ScriptMonkeyScriptMonkey 

Dynamic Components Problems - commandButton failing

I've got a problem that I can't seem to resolve.  Here's my VisualForce code and Apex code.  When I uncomment out the expressions line in the Apex code, clicking the "save" button just loads the whole controller, with that line commented out, clicking save just executes the save function and triggers that two debug statements as I expect it to.

 

Any advice is very welcome, I've been staring at this all day.

 

VF:

<apex:page controller="testSaveController" showHeader="false" cache="false" 
	sidebar="false" standardStylesheets="false">
	<apex:form id="theForm">
		<apex:dynamicComponent componentValue="{!fieldDisplay}" />
		<center>
		<apex:commandButton action="{!save}" value="Save" id="theButton" rerender="theForm"/>
		</center>
	</apex:form>
</apex:page>

 

APEX:

public with sharing class testSaveController
{
	public LIST<string> fieldValues					{ get; set; }
	
	public testSaveController()
	{
		//constructor
	}
	
	public Component.Apex.OutputPanel getFieldDisplay()
	{
		fieldValues = new LIST<string>();
		fieldValues.add('testVal');
		
		Component.Apex.OutputPanel formContainer = new Component.Apex.OutputPanel();
		
		Component.Apex.InputText dynInpText = new Component.Apex.InputText();
//		dynInpText.expressions.value = '{!fieldValues[0]}';
		dynInpText.id = 'field0';
		formContainer.childComponents.add(dynInpText);

		return formContainer;
	}
	
	public void save()
	{
		system.debug('----------------------------------------------');
		system.debug(fieldValues);
	}
}

 

 

aballardaballard

Hm I seem to remember there is a known issue with using a subscripted reference in an input component where it refers to a list element.  i.e. I think {!fieldValues[0]} probably doesn't work in inputText even if you aren't using dynamic components.  Where fieldValues is a list or map reference.   It does work for an output component. 

 

Can you rework your page to not use a list reference here?

 

ScriptMonkeyScriptMonkey

aballard wrote:

Hm I seem to remember there is a known issue with using a subscripted reference in an input component where it refers to a list element.  i.e. I think {!fieldValues[0]} probably doesn't work in inputText even if you aren't using dynamic components.  Where fieldValues is a list or map reference.   It does work for an output component. 

 

Can you rework your page to not use a list reference here?

 


Unfortunately I can't think of a way.  The app I'm writing is going to build a form dynamicly based on data from an Object, so I don't know before I start how many fields there are, and I'd hate to have to just name fields as variables value1 through value50 or whatever, because then you're either wasting memory space or not having enough. 

 

aballardaballard

You might want to open a support case to see if you can get the priority of fixing this raised.   (If you do, tell support to link it to W-1065879)

sfdcfoxsfdcfox

My apologies for bringing this back up, but it appears that W-1065879 has reared its ugly head in my case, too, except I'm binding to a Map<Id,Boolean> in the (apparently vain) attempt to circumvent the need for a wrapper class. I just thought I'd throw that in here. I'm going to try to submit a case with support in the interim.