Reputation: 86
In continuation of building a custom tag, all the processes have been done and are working accurately except passing parameters to beans method. i have tried but unable to pass the parameters, following is the code.
web.xml
<context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>/WEB-INF/pinnacleTags.taglib.xml</param-value>
</context-param>
tabib
<?xml version="1.0" encoding="UTF-8"?>
<facelet-taglib>
<namespace>pinnacleTags/facelets</namespace>
<tag>
<tag-name>PinnacleCombo</tag-name>
<source>buttonPanel.xhtml</source>
<attribute>
<name>textBoxValue</name>
</attribute>
<attribute>
<name>caption</name>
</attribute>
<attribute>
<name>btnCaption</name>
</attribute>
<attribute>
<name>textBoxWidth</name>
</attribute>
<attribute>
<name>btnHeight</name>
</attribute>
<attribute>
<name>btnWidth</name>
</attribute>
<attribute>
<name>actionListenerBean</name>
</attribute>
<attribute>
<name>actionListenerBean</name>
<method-signature>void actionListener(javax.faces.event.ActionEvent)</method-signature>
</attribute>
<attribute>
<name>actionListenerMethod</name>
<method-signature>method-signature="java.lang.String action(javax.faces.event.ActionEvent)"</method-signature>
</attribute>
</tag>
</facelet-taglib>
the component
<ui:composition>
<div>
<h:outputLabel value="#{caption}" />
<p:inputText value="#{textBoxValue}" style="width: #{textBoxWidth}; " />
<p:commandButton type = "submit"
value = "#{btnCaption}"
actionListener="#{actionListenerBean[actionListenerMethod]}"
style="height: #{btnHeight}; width: #{btnWidth};" />
</div>
</ui:composition>
and finally the useage
<pt:PinnacleCombo id="clientID"
textBoxValue="#{customTags.clientID}"
caption="Client ID: "
textBoxWidth="150px"
btnHeight="35px"
btnCaption="Press"
actionListenerBean="#{customTags}"
actionListenerMethod="btnPressed"/>
I donot know how to pass parameters to the menthod, pls suggest.
Upvotes: 0
Views: 421
Reputation: 86
finally as @Selaron suggested, the custom tag, after using omnifaces, is
<ui:composition>
<h:outputLabel value="#{caption}" />
<p:inputText value="#{textBoxValue}" style="width: #{textBoxWidth}; " />
<o:methodParam name="method" value="#{actionListenerBeanMethod}" />
<p:commandButton type = "submit"
value = "#{btnCaption}"
actionListener="#{method}"
style="height: #{btnHeight}; width: #{btnWidth};" />
</ui:composition>
and the function call was simple
actionListenerBeanMethod="#{customTags.btnPressed('Value Passed')}"
Thanx @Selaron for help.
Upvotes: 1