+ Start a Discussion
Naresh Krishna.ax1176Naresh Krishna.ax1176 

How to get the visualforce page component value in controller ?

Hi All,

 

By using dynamicComponent concept am able to create visualforce component (inputText).

But how to get the entered text value when I click on commandButton 'test' ?

 

Please see the code below:

Page:

<apex:page controller="SimpleDynamicController" sidebar="false" >
<apex:form >
<apex:dynamicComponent componentValue="{!sampleInputTxt}" /> 

<apex:commandButton action="{!testSampleInputTxt}" value="test"/>

</apex:form>
</apex:page>

 

Controller:

public class SimpleDynamicController {


public Component.Apex.inputText getSampleInputTxt() {
Component.Apex.inputText inText = new Component.Apex.inputText();
inText.id = 'TextId';
return inText;
}


public PageReference testSampleInputTxt() {

 

//Print the inputText value entered

return null;
}

}

 

Could anyone please help me on this.

 

Thanks.