0

I am trying to create a datatable composite component, this component needs to be used by two groups of developers, one who are using Spring web flow and they need an action attribute for the command link inside the composite component datatable and the others need the actionListener attribute.

I would like to use the same xhtml for both cases. Is that feasible?

  <composite:attribute name="isWebFlow" />   

Would an attribute like above help me configure? The problem is that I have many command links in the datatable composite component and hence I cannot repeat them / render them based on the condition like :

<c:if test="#{cc.attrs.isWebFlow eq 'true'}">  
     <p:commandLink styleClass="filter #{cc.attrs.styleClass}" action="#{cc.attrs.action}"/>
</c:if>    

<c:if test="#{cc.attrs.isWebFlow eq 'false'}">  
    <p:commandLink styleClass="filter #{cc.attrs.styleClass}" actionListener="#{cc.attrs.actionListener}"/>
</c:if>  

Is there any other way to do this and re use the xhtml? Thanks in advance.

SnS
  • 175
  • 2
  • 16

1 Answers1

0

Try using rendered attribute:

<p:commandLink styleClass="filter #{cc.attrs.styleClass}" action="#{cc.attrs.action}" rendered="#{isWebFlow}"/> <p:commandLink styleClass="filter #{cc.attrs.styleClass}" action="#{cc.attrs.action}" rendered="#{!isWebFlow}"/>
Szarpul
  • 1,531
  • 11
  • 21
  • I have many command links like this in the xhtml and I cannot keep repeating the code like this as already mentioned in the question. – SnS Sep 29 '14 at 10:33