如何通过控制器显示组件?
我需要注册一个用户,然后我想调用
例如,用图标显示错误或成功消息。
<rich:popupPanel id="popup" modal="false" autosized="true" resizeable="false">
<f:facet name="header">
<h:outputText value="Simple popup panel" />
</f:facet>
<f:facet name="controls">
<h:outputLink value="#"
onclick="#{rich:component('popup')}.hide(); return false;">
X
</h:outputLink>
</f:facet>
<p>Any content might be inside this panel.</p>
</rich:popupPanel>
在我的控制器中验证注册过程后,我该如何做到这一点? 我可以调用
,但我认为带有一些图标和状态消息的 popupPanel 更适合用户。
I need to register an user and after that I would like to call a <rich:popupPanel>
for example to show the error or successful message with an icon.
<rich:popupPanel id="popup" modal="false" autosized="true" resizeable="false">
<f:facet name="header">
<h:outputText value="Simple popup panel" />
</f:facet>
<f:facet name="controls">
<h:outputLink value="#"
onclick="#{rich:component('popup')}.hide(); return false;">
X
</h:outputLink>
</f:facet>
<p>Any content might be inside this panel.</p>
</rich:popupPanel>
How do I do that after the validation of the register process in my controller ?
I could call a <h:message>
, but I think a popupPanel with some icon and the status message would be more appropriate to the user.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一般来说,您只需在 bean 的操作方法中设置一些(布尔)切换或特定对象属性,然后在相关包含组件的
rendered
属性中使用该属性。下面是一个简单布尔值的示例:with
您还可以设置一些对象属性,然后检查它是否不为空或 null。例如,当
User
在注册后成功保存并因此从数据库获得ID时:注意:在您的
的特定情况下,您还可以使用show
属性而不是rendered
属性。唯一的区别是,当
show
为false
时,组件仍会呈现,但随后使用 CSSdisplay:none;
使其在视觉上可见隐藏在 HTML DOM 树中,以便您只需使用 JavaScript 即可重新显示它。另请参阅:
In general, you'd just set some (boolean) toggle or a specific object property in the bean's action method which is then used in the
rendered
attribute of the containing component in question. Here's an example with a simple boolean:with
You can also set some object property and then check if it is not empty or null. E.g. when the
User
is successfully saved after registration and thus got an ID from the DB:Note: in the particular case of your
<rich:popupPanel>
, you can also use theshow
attribute instead ofrendered
attribute.The only difference is that when
show
isfalse
, the component is still rendered, but then with CSSdisplay:none;
so that it is visually hidden in the HTML DOM tree, so that you can redisplay it with just JavaScript.See also: