I have a problem with a composite component.
This component uses the componentType attribute of the interface declaration to bind the component (and its attributes) to a backing bean.
This works as long as the composite component attributes are not updated.
When I look closely at the logs, it seems that the backing bean attributes are always updated with the initial value of the attributes.
My xhtml component looks like :
<composite:interface componentType="timelineMandats">
<composite:attribute name="augmentedSen" type="fr.senat.beans.AugmentedSen" required="true"/>
<composite:attribute name="timelineWidth" required="false" default="800"/>
<composite:attribute name="dateMin" required="false" type="java.util.Date"/>
<composite:attribute name="dateMax" required="false" type="java.util.Date"/>
<composite:attribute name="highlightDate" required="false" type="java.util.Date"/>
<composite:attribute name="forceMinMax" required="false" default="false"/>
</composite:interface>
<composite:implementation>
<p:outputPanel>
<p:scrollPanel style="width:820px; height:200px;text-align:center;">
<p:graphicImage id="imgTimeline" value="#{cc.timelineSenatoriaux}"/>
</p:scrollPanel>
<p:panelGrid columns="4">
<h:outputText value="Intervalle :"/>
<p:calendar value="#{cc.dateMin}" pattern="dd/MM/yyyy" mode="popup" showOn="button">
<p:ajax event="dateSelect" update="imgTimeline"/>
<p:ajax event="change" update="imgTimeline"/>
</p:calendar>
<p:calendar value="#{cc.dateMax}" pattern="dd/MM/yyyy" mode="popup" showOn="button">
<p:ajax event="dateSelect" update="imgTimeline"/>
<p:ajax event="change" update="imgTimeline"/>
</p:calendar>
<p:commandButton value="Mettre à jour" update="imgTimeline"/>
</p:panelGrid>
</p:outputPanel>
</composite:implementation>
The backing bean is declared like :
@FacesComponent("timelineMandats")
public class TimelineMandats extends TimelineBase {
AugmentedSen asen;
public AugmentedSen getAugmentedSen() { return asen; }
public void setAugmentedSen(AugmentedSen asen) { this.asen = asen; }
// other accessors and stuff
}
Its base class derives from UIComponentBase and extends NamingContainer :
public class TimelineBase extends UIComponentBase implements Serializable,NamingContainer {
...
}
I also tried to derive from UINamingContainer, UIComponent, etc.
The "AugmentedSen" type is serializable and used in many other places.
The composite component is called with el expressions as some parameters :
<sen:timelineMandatsSenateurs augmentedSen="#{selectionContext.selectedSen}" timelineWidth="700" forceMinMax="true"/>
I can see in the logs that attributes are properly set, but that the value set never changes along with the result of the el expression evaluation. The value of selectedSen changes as the user picks an item in another component.
What surprises me is that if I remove the componentType attribute of the interface declaration and just output the cc.attrs.augmentedSen value, it is properly updated. I can understand that only one instance of the backing bean exists. But why are the attributes not properly updated ?
I tried to chead by giving the composite component instance a parametric id ( something like
<sen:timelineMandatsSenateurs id="tl_#{selectionContext.selectedSen.sen.senmat}" augmentedSen="#{selectionContext.selectedSen}" timelineWidth="700" forceMinMax="true"/>
).
I also encapsulated it in a primefaces p:outputPanel with dynamic="true", rendered only when the parameter is not null, but this changes nothing.
<p:outputPanel id="graph" dynamic="true" rendered="#{not empty selectionContext.selectedSen}">
<sen:timelineMandatsSenateurs augmentedSen="#{selectionContext.selectedSen}" timelineWidth="700" forceMinMax="true"/>
</p:outputPanel>
So how can I put it so that the EL expression passed as parameter is reevaluated and the attribute properly updated ?
Many thanks in advance.
I am using :
- tomcat 6.0.33
- MyFaces 2.1.7
- PrimeFaces 3.2
- CODI 1.0.5
- OWB 1.1.3