I am working on a project that consists of a Visualforce component that loads some data from a JSON file and constructs picklists/comboboxes with cross value dependencies, so that developers can refer to these objects in VF pages easily and don't have to write much controller-level code.
This is my component:
<apex:component controller="DependantPicklistController">
<apex:attribute name="parentController" type="DependantPicklistBase" required="true" description="Controlador" assignTo="{!pageController}"/>
<apex:attribute name="plname" type="String" required="true" description="Picklist" assignTo="{!name}"/>
<div id="{!name}">
<apex:outputText value="{!name}"/>
<apex:selectlist value="{!selectedValue}">
<apex:selectOptions value="{!picklistValues}"/>
<apex:actionSupport event="onselect" action="{!reloadChildren}" rerender="{!dependantPicklists}"/>
</apex:selectlist>
</div>
</apex:component>
As the Id
property of Visualforce components HAS to be literal, I cannot wrap my component body in a OutputPanel like this:
<apex:outputPanel id="{!name}">[component body]</apex:outputPanel>
Therefore, because I want to automatise the rerendering process, I ended setting the Id
property of the <div>
tag.
However, providing the <div>
Id
to the <apex:actionsupport>
tag rerender
property doesn't seem to work.
Is there any way to set these arbitrary HTML elements to rerender once the user selects a value from the picklist?
Thank you in advance!
apex:outputPanel id="mypanel"
, that's it. It must work because the generated panel-id will be unique inside your page (likej_id0:myForm:j_id38:mypanel
)