You need to sign in to do that
Don't have an account?
krishna mohan 29
can we get back given value in apex:inputfield after rerendering the output panel?
Hi all,
I need inputfield capability to get given input even after it is rerendered(hidden or shown) onchange of picklist value.
like if option 'a' is selected in picklist, the apex:inputfield with type textarea is shown and user enters data, and selecting 'b' hides rerenders and hides the field, and again if 'a' is selected i need field shown with previously given data in the field.
Thanks in advance.
I need inputfield capability to get given input even after it is rerendered(hidden or shown) onchange of picklist value.
like if option 'a' is selected in picklist, the apex:inputfield with type textarea is shown and user enters data, and selecting 'b' hides rerenders and hides the field, and again if 'a' is selected i need field shown with previously given data in the field.
Thanks in advance.
try this code
VisualForce:
<apex:page controller="Sample">
<apex:form >
<apex:actionFunction name="changeBoolCall" action="{!changeBool}"/>
<apex:pageblock id="pg">
<apex:pageblockSection >
<apex:pageblockSectionItem >
Select currency :
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:selectList value="{!curency}" size="1" multiselect="false">
<apex:selectOption itemLabel="--- None ---" itemValue="none"/>
<apex:selectOption itemLabel="Indian Rupee" itemValue="inr"/>
<apex:actionSupport event="onchange" action="{!changeBool}" reRender="pg"/>
</apex:selectList>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
Enter the amount:
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:inputtext value="{!amount}" rendered="{!curencyBool}"/>
</apex:pageblockSectionItem>
</apex:pageblockSection>
</apex:pageblock>
</apex:form>
</apex:page>
Apex:
public class Sample
{
public String curency {get;set;}
public String amount {get;set;}
public Boolean curencyBool {get;set;}
public sample()
{
curency = 'none';
if(curency == 'none')
{
curencyBool = false;
}
}
public void changeBool()
{
if(curency != 'none')
{
curencyBool = true;
}
else
{
curencyBool = false;
}
}
}
you can take reference of this code
as we can use rerender
rendered="{!IF( Campaign.Primary_Campaign_Attribute__c == 'Religious Affiliation', true, false )}" >
I had tried similar one but can we do that if we are using action:region to process request for the picklist.
<apex:form >
<apex:actionFunction name="changeBoolCall" action="{!changeBool}"/>
<apex:pageblock id="pg">
<apex:pageblockSection >
<apex:pageblockSectionItem >
Select currency :
</apex:pageblockSectionItem>
<apex:pageblockSectionItem ><apex:actionRegion >
<apex:selectList value="{!curency}" size="1" multiselect="false">
<apex:selectOption itemLabel="--- None ---" itemValue="none"/>
<apex:selectOption itemLabel="Indian Rupee" itemValue="inr"/>
<apex:selectOption itemLabel="Chinese Rupee" itemValue="inr2"/>
<apex:actionSupport event="onchange" action="{!changeBool}" reRender="pg"/>
</apex:selectList></apex:actionRegion>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:inputfield value="{!sample.amount}" rendered="{!curencyBool}"/>
</apex:pageblockSectionItem>
</apex:pageblockSection>
</apex:pageblock>
</apex:form>
</apex:page>
When trying with similar code using input field and action region the value is refreshing and not returning to the field.
Ya,if you are using the action region it particularly refresh the values so it clear the value.then we have two chances.one is prior value in workflow another one is view state in vf and apex.