在继续构建自定义标记时,除了将参数传递给been方法之外,所有进程都已完成并正在准确工作。我试过了,但无法传递参数,下面是代码。
web.xml
<context-param>
<param-name>facelets.LIBRARIES</param-name>
<param-value>/WEB-INF/pinnacleTags.taglib.xml</param-value>
</context-param>塔比卜
<?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>组件
<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>最后是使用
<pt:PinnacleCombo id="clientID"
textBoxValue="#{customTags.clientID}"
caption="Client ID: "
textBoxWidth="150px"
btnHeight="35px"
btnCaption="Press"
actionListenerBean="#{customTags}"
actionListenerMethod="btnPressed"/>我不知道如何把参数传递给薄荷糖,请建议。
发布于 2019-11-22 11:20:30
最后,正如@Selaron所建议的那样,自定义标签在使用总括之后是
<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>函数调用很简单
actionListenerBeanMethod="#{customTags.btnPressed('Value Passed')}"Thanx @Selaron寻求帮助。
https://stackoverflow.com/questions/58949518
复制相似问题