You need to sign in to do that
Don't have an account?
Ravi K
how to bind list of dynamic boxes from VF page to controller, values are not binding when using action function with Immediate=true property
I have a requirement to capture list of names using Dynamic boxes on VF page. I am using action function for this, but behavior is getting changed based on attribute "Immediate" of action function. if Immediate="true" values are not binding to list showing blanks. if "false" its binding values correctly. But i have to use this with Immediate=true.
Below is my code: Controller:
public with sharing class DynamicTextbox {
public list<AUser> lstuser{get;set;}
public DynamicTextbox(ApexPages.StandardController controller) {
lstuser = new list<Auser>();
lstuser.add(new Auser(''));
}
public void AddName() {
lstuser.add(new Auser(''));
}
public class Auser{
public string name{get;set;}
public Auser(string name){
this.name=name;
}
}
}
VF page:
<apex:page standardController="account" extensions="DynamicTextbox">
<apex:form >
<apex:actionFunction id="AddAuthorizedUser" name="AddName" action="{!AddName}" reRender="Outpanel" immediate="true"/>
<apex:outputPanel id="Outpanel" >
<apex:actionRegion >
<apex:repeat value="{!lstuser}" Var="Auser" id="samrr">
<apex:inputtext value="{!Auser.name}" styleClass="form-control"/>
</apex:repeat>
<button type="button" onclick="AddName();"> <B>+</b> </button>
</apex:actionRegion>
</apex:outputPanel>
</apex:form>
</apex:page>
Below is my code: Controller:
public with sharing class DynamicTextbox {
public list<AUser> lstuser{get;set;}
public DynamicTextbox(ApexPages.StandardController controller) {
lstuser = new list<Auser>();
lstuser.add(new Auser(''));
}
public void AddName() {
lstuser.add(new Auser(''));
}
public class Auser{
public string name{get;set;}
public Auser(string name){
this.name=name;
}
}
}
VF page:
<apex:page standardController="account" extensions="DynamicTextbox">
<apex:form >
<apex:actionFunction id="AddAuthorizedUser" name="AddName" action="{!AddName}" reRender="Outpanel" immediate="true"/>
<apex:outputPanel id="Outpanel" >
<apex:actionRegion >
<apex:repeat value="{!lstuser}" Var="Auser" id="samrr">
<apex:inputtext value="{!Auser.name}" styleClass="form-control"/>
</apex:repeat>
<button type="button" onclick="AddName();"> <B>+</b> </button>
</apex:actionRegion>
</apex:outputPanel>
</apex:form>
</apex:page>
If you use an action region - you can not need to process these validations that are required when adding a new row here like so: try Changing your button from a Button to a commandButton and use rerender like this - reRendering the component that contains your other items will also work with actionRegion - I have noticed that the HTML 'button' tag will nullify this behavior and you will get default processing of the form instead. I added a little output text here in my testing that just shows my list count - but this is tested and DOES work.
Hope this helps.
Thanks,
Nagendra
All Answers
If you use an action region - you can not need to process these validations that are required when adding a new row here like so: try Changing your button from a Button to a commandButton and use rerender like this - reRendering the component that contains your other items will also work with actionRegion - I have noticed that the HTML 'button' tag will nullify this behavior and you will get default processing of the form instead. I added a little output text here in my testing that just shows my list count - but this is tested and DOES work.
Hope this helps.
Thanks,
Nagendra