1

I have a dynamically generated picklist, which generates fine below:

> public string ConNames {get;set;} 
> List<SelectOption> options = new
> List<SelectOption>(); Public list<SelectOption> getAccCons(){
>     system.debug('>>> Generating contact list');
>     List<Contact> conList = New List<Contact>();
>     conList = [SELECT Id, Name FROM Contact WHERE AccountId = :AccId];
>     options.add(new SelectOption('--None--','--None--')); 
>     For (Contact con : ConList){
>         options.add(new SelectOption(con.Id,con.Name)); 
>         options.add(new SelectOption('Create New Contact','Create New Contact'));            
>     }
>     return options;}

Which is used in a VF page as below:

    <apex:selectList value="{!ConNames}" size="1" label="Select Contact">
        <apex:selectOptions value="{!AccCons}"/>
        <apex:actionSupport event="onchange" reRender="test"/>
    </apex:selectList> 

If the select value = 'Create New Contact' I wanted to rerender the outputpanel 'Test'. I'm currently trying to use:

rendered="{!ConNames = 'Create New Contact'}">

But this is always returning false as ConNames is always null, what am I missing? I can see the rerender is working.

3
0

{!ConNames = 'Create New Contact''} You are having single quote twice. Try fixing that. Thanks.

2
  • Sorry typo in the post I've updated it. The issue is that ConNames is always null, so at the moment the render attribute isn't the issue. Sorry if that wasn't clear. – Girbot Oct 8 '14 at 13:08
  • ConNames where are you geting it? it is supposed to be null – Shanker Paudel Oct 8 '14 at 13:15
0

Use VF Page function

ISPICKVAL : Determines if the value of a picklist field is equal to a text literal you specify.

Refer this documentation

If in case you get some save error, please check this link for workaround or use == for comparison.

2
  • Thanks for the answer, I wasn't clear in my question - ConNames is always null at the moment so the render part isn't the issue yet. I've updated my question to be clearer. – Girbot Oct 8 '14 at 13:11
  • @Girbot Can you please post the further code including outputpanel too. – Aditi Jain Oct 8 '14 at 13:29
0

I now have this working it appears I was hitting the same issue as in this answer by LaceySnr: How can an apex:pageBlockSection be rerendered if it originally has a render value of false?

I started my page again from scratch and gradually rebuilt it, the issue was to do with how I had used the <apex:pageBlockSections>

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.