使用和隐藏/显示面板(hide/show the panel using and )

编程入门 行业动态 更新时间:2024-10-27 00:29:54
使用隐藏/显示面板(hide/show the panel using and )

我是jsf和primefaces的新手。我想实现它,同时点击按钮两个链接应该启用,同时再次单击相同的按钮,两个链接被禁用。 我创建了一个使用<h:commandButton>和java bean隐藏show但不知道<p:commandButton>和<p:outputPanel>的示例。

我已经实现了这一点,点击链接将启用2链接。

问题是再次点击它必须被禁用,这是无效的

I am a new to jsf and primefaces.I want to implement that while clicking on button two link should be enable while clicking on the same button again that two link become disabled. I have created a example using <h:commandButton> and java bean to hide show but no idea with the <p:commandButton> and <p:outputPanel>.

I have achieved that while click on the link the 2 link will be enable.

Problem is but again clicking on that it has to be disable which was not working

最满意答案

如果我理解你:

<h:form id="mainform"> <p:commandButton value="#{testBean.enabled ? 'Hide' : 'Show'}" action="#{testBean.toggle()}" update="links, @this"/> <p:outputPanel id="links"> <p:link value="link1" href="http://www.stackoverflow.com" rendered="#{testBean.enabled}"/> <p:spacer width="10"/> <p:link value="link2" href="http://www.stackoverflow.com" rendered="#{testBean.enabled}"/> </p:outputPanel> </h:form>

豆:

private Boolean enabled = false; // + getter/setter public void toggle() { enabled = !enabled; }

If I understand you:

<h:form id="mainform"> <p:commandButton value="#{testBean.enabled ? 'Hide' : 'Show'}" action="#{testBean.toggle()}" update="links, @this"/> <p:outputPanel id="links"> <p:link value="link1" href="http://www.stackoverflow.com" rendered="#{testBean.enabled}"/> <p:spacer width="10"/> <p:link value="link2" href="http://www.stackoverflow.com" rendered="#{testBean.enabled}"/> </p:outputPanel> </h:form>

Bean:

private Boolean enabled = false; // + getter/setter public void toggle() { enabled = !enabled; }

更多推荐

commandButton>,link,电脑培训,计算机培训,IT培训"/> <meta name="descri

本文发布于:2023-08-05 17:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1435821.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:面板   hide   panel   show

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!