简体   繁体   English

如何在加载时隐藏RichFaces组件?

[英]How to hide RichFaces component on load?

I would like to hide selected rendered component (for example: label) on page load. 我想在页面加载时隐藏选定的渲染组件(例如:label)。 This gives mi opportunity to subsequently show component after user action (for example: when user clicks link). 这使mi有机会在用户操作后(例如:当用户单击链接时)显示组件。

Here is example: 这是示例:

<a4j:outputPanel id="myPanel">
    <h:outputText value="Text 1" />
    <h:outputText value="Text 2" />
</a4j:outputPanel>
<a4j:commandLink ajaxSingle="true" onclick="#{rich:component('myPanel')}.show()">
    <h:outputText value="Show panel"/>
</a4j:commandLink>

Panel myPanel should be hidden at the begining (after page load) and should apper when user clicks link. Panel myPanel应该在开始时(页面加载后)隐藏,并且在用户单击链接时自动显示。

Can you give me please advice how to do that? 您能给我建议如何做吗?

Thanks, Rafal 谢谢,拉法尔

Here is solution from RichFaces forum which works fine. 这是RichFaces论坛的解决方案,效果很好。

CSS: CSS:

.hideOnLoad {
    display: none;
}

Page fragment: 页面片段:

<a4j:outputPanel id="myMessage" styleClass="hideOnLoad">
    <h:outputText value="This is my first message" />
    <h:outputText value="This is my second message" />
</a4j:outputPanel>
<br/>
<a4j:commandLink ajaxSingle="true"
    onclick="$('myMessage').removeClassName('hideOnLoad');"
    value="Show my message" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM