0

I'm stuck in climax work,please give suggestion

I have picklist saying

test1
yes
No 

after selecting "yes" value it will show one more picklist. (This one rendering/working perfectly)

test2
yes 
no

Here after selecting "yes" value one field should show But this field is some times is showing but some times is not showing , I have given correct outputpanels for rerender and render even it's not coming sometimes. WHY??

Please give suggestions for how to work on this.

VF

<apex:inputField value="{!lead.test1}" >
<apex:actionsupport event="onchange" action="{!showhide}" status="loadStatus" rerender="t2"/></apex:inputField>
<apex:outputpanel id="t2">
<apex:inputField value="{!lead.test2}" style="width:250px" rendered="{!tbb1}">
<apex:actionsupport event="onchange" status="loadstatus" action="{!showhide}" rerender="t3"/></apex:inputField>
</apex:outputpanel>
<apex:outputpanel id="t3">
<apex:inputField value="{!lead.test3}" rendered="{!tbb2}">
</apex:outputpanel>

Apex

public void showhide() {
 if(lead.test1=='Yes')tbb1=true; else tbb1=false;

 if(lead.test2=='Yes')tbb2=true; else tbb2=false;

}
  • I can't explain why the problem is occurring but suggest you add an id to an element that contains all the elements you show in the question and rerender that. – Keith C Dec 6 '14 at 21:00
  • Like that only i'm added , I'm added field in outputpanel then rerendering it – Sfkn Dec 6 '14 at 21:16
  • Your pick lists have lowercase yes but apex is looking for Yes. Is that a typo in the question? If yes, please edit your post – cropredy Dec 7 '14 at 2:34
1

With this controller:

public class A {
    public Lead lead {get; set;}
    public Boolean tbb1 {get; set;}
    public Boolean tbb2 {get; set;}
    public A() {
        lead = new Lead();
    }
    public void showhide() {
        if(lead.test1__c=='Yes')tbb1=true; else tbb1=false;
        if(lead.test2__c=='Yes')tbb2=true; else tbb2=false;
    }
}

and this page:

<apex:page controller="A">
<apex:form>
    <apex:inputField value="{!lead.test1__c}" >
        <apex:actionsupport event="onchange" action="{!showhide}" status="loadStatus" rerender="t2"/>
    </apex:inputField>
    <apex:outputpanel id="t2">
        <apex:inputField value="{!lead.test2__c}" style="width:250px" rendered="{!tbb1}">
            <apex:actionsupport event="onchange" status="loadstatus" action="{!showhide}" rerender="t3"/>
         </apex:inputField>
    </apex:outputpanel>
    <apex:outputpanel id="t3">
        <apex:inputField value="{!lead.test3__c}" rendered="{!tbb2}">
        </apex:inputField>
    </apex:outputpanel>
    <apex:actionStatus id="loadstatus" startText="Loading..."/>
</apex:form>
</apex:page>

and 3 picklist fields added to Lead I could not reproduce your problem. The third field was displayed and hidden as expected. This was using Chrome.

It may be that your actual page and controller contain other logic that is interfering. I suggest you test with the above code and page and see if the problem persists for you.

To debug (in Chrome) you should make use of the "Network" tab of the "Developer Tools" that will show you the re-render requests and responses.

| improve this answer | |
0

I notice the following things in your code. 1. All visualforce markup tags are generally camel case but I see that your actionsupport tags in the code mentioned above should be . 2. The rerender should be changed to reRender as well. 3. Set the attribute immediate="true" for the actionSupport tag and verify if the functionality works as desired. If yes, then there might be server side validations that might be interfering with the postback thus causing the rendering to behave unexpectedly.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.