function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mr209204mr209204 

Dynamic Edit Page - Visual Force

I've created some visual force pages using this example

http://wiki.apexdevnet.com/index.php/Visualforce_DynamicEditPage

I've been able to create the example and some other pages successfully and replacing the input field from the drop down menu to check boxes which isn't too hard. I am now trying to create a page and trying to do this with a Multi-Select Picklist and it is not quite working. Any help is greatly appreciated.

This is what I have so far.

Contact_Type__c is the multi-select picklist

Code:
<apex:page standardController="Contact" tabStyle="Contact" >
<apex:form >
    <apex:sectionheader title="Create New Contact"> 
        <apex:actionregion >   
        <apex:pageBlock title="Contact Information" id="thePageBlock" mode="edit">
        
            <apex:pageBlockSection title="Basic Information" columns="1">
                <apex:inputfield value="{!contact.firstName}" />
                <apex:inputfield value="{!contact.lastName}" />
                <apex:inputfield value="{!contact.MailingStreet}" />
                <apex:inputfield value="{!contact.MailingCity}" />
                <apex:inputfield value="{!contact.MailingState}" />
                <apex:inputfield value="{!contact.MailingCountry}" />
                <apex:inputfield value="{!contact.MailingPostalcode}" />
                <apex:inputfield value="{!contact.Phone}" />
                <apex:inputfield value="{!contact.MobilePhone}" />
                <apex:inputfield value="{!contact.Fax}" />
                <apex:inputfield value="{!contact.Email}" />

                <apex:pageBlockSectionItem>                        
                        <apex:outputLabel value="Contact Type"/>                        
                        <apex:outputPanel >                            
                            <apex:inputfield value="{!contact.Contact_Type__c}">                                
                                <apex:actionSupport event="onchange" rerender="thePageBlock"status="status1"/>                            
                            </apex:inputfield>                           
                            <apex:actionStatus startText="applying value..." id="status1"/>                        
                        </apex:outputPanel>                    
                </apex:pageBlockSectionItem> 
                
                <apex:pageBlockSection title="Volunteer" Columns="1" rendered="{!contact.Contact_Type__c = 'Volunteer'}">
                    <apex:inputfield value="{!contact.Volunteer_Certifications__c}" />
                </apex:pageBlockSection>

            </apex:pageBlockSection>
            
        </apex:pageBlock>           
        </apex:actionregion>
    </apex:sectionheader>
</apex:form>
</apex:page>

 

TehNrdTehNrd

mr209204 wrote:
with a Multi-Select Picklist and it is not quite working.



What does "not quite working" mean. I think a little more detail is required.
mr209204mr209204
Sorry about that.

What I want to accomplish is...when I select an item and add it to the selected section on the mulit-select picklist more fields will show up. When I select another item the same happens. When I move the item back the fields that correspond to that selection go away. This is what I would like to figure out/get help on.


I've been able to do this with check boxes and if I cannot do this with a Mulit-select picklists then I will go back to using check boxes.
TehNrdTehNrd
Gotcha. I'm not sure how the values are returned with a multi select list but rather than a equals statement in the rendered attribute try contains. I'm not sure if this will work but it's worth a try.


<apex:pageBlockSection title="Volunteer" Columns="1" rendered="{!CONTAINS(contact.Contact_Type__c,'Volunteer')}">

mr209204mr209204
Was wroth a try. That line displays the section whether or not I've made a selection or not.

Any other suggestions?
TehNrdTehNrd
I did some more playing around with it and it looks like the actionSupport is never being executed. I tried changing the event to onclick an onchange but it made no difference. I'm not sure what other even would even work so I'm not sure this will be possible with multi select lists.
mr209204mr209204
Seems that way. I've been tinkering with it for a while now. Is there a complete list of all the tags, values and such out there somewhere?
ColeCole
Make <apex:actionSupport.../> a child of "outputPanel" (instead of "inputField").

This way you'll be firing AJAX events on the "invisible" outputPanel that contains your multi-select picklist, instead of the multi-select picklist itself.

For this to work, you'll probably also have to change the event type to "onmouseover", which will work much better than the other Java script events (like "onchange").

Solution:
<apex:pageBlockSectionItem>
   <apex:outputLabel value="Contact Type"/>
   <apex:outputPanel>
      <apex:inputfield value="{!contact.Contact_Type__c}"/>
      <apex:actionSupport event="onmouseover" rerender="thePageBlock"status="status1"/>
      <apex:actionStatus startText="applying value..." id="status1"/>
   </apex:outputPanel>
</apex:pageBlockSectionItem>
mr209204mr209204
I will try that. Awesome thanks.
mr209204mr209204
The problem with this is that every time you mouse over a selection it refreshes. If there are selections that require scrolling to select you cannot select them because it refreshes back to the top automatically. It is recognizing the action though.

Also you cannot deselect the item after it is selected.


Message Edited by mr209204 on 09-02-2008 10:01 AM
CTU007CTU007

Must the pageBlock id="thePageBlock"?

 

i used id="editblock" and it did not work, then I changed to "thePageBlock", it worked....

 

Something is missing?

 

 

TehNrdTehNrd
Make sure you update this line:
rerender="thePageBlock"
Message Edited by TehNrd on 07-29-2009 11:11 AM
CTU007CTU007

I remember I did changed both places.... and it did not work...

 

Now I tried again with the different name, and it works.

 

Not sure why.