Richfaces:在弹出窗口中显示详细信息[命令按钮,操作和弹出窗口] [英] Richfaces: show details in popup [commandbutton, action and popupPanel]

查看:60
本文介绍了Richfaces:在弹出窗口中显示详细信息[命令按钮,操作和弹出窗口]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像这样的xhtml:

I have a xhtml like this:

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.org/schema/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml">

    <ui:define name="body">
        <h:body>
            <h:form id="form">
                <rich:panel>
                    <rich:dataTable value="#{scriptConsole.serversList}" var="server">

                        <f:facet name="header">
                            <h:outputText value="Servers" />
                        </f:facet>

                        <rich:column>
                            <f:facet name="header">Name</f:facet>
                            <h:outputText value="#{server.name}" />
                        </rich:column>

                        <rich:column>
                            <f:facet name="header">Actions</f:facet>
                            <a4j:commandButton value="view" oncomplete="#{rich:component('modalScripts')}.show();" action="#{scriptConsole.setServerSelected(server)}"/>
                        </rich:column>
                    </rich:dataTable>
                </rich:panel>
                <rich:popupPanel id="modalScripts" modal="true" autosized="true"
                    resizeable="false">
                    <f:facet name="controls">
                        <h:outputLink value="#"
                            onclick="#{rich:component('modalScripts')}.hide(); return false;">X</h:outputLink>
                    </f:facet>
                    <h:outputText
                            value="#{scriptConsole.serverSelected.name}" />

                </rich:popupPanel>
            </h:form>
        </h:body>
    </ui:define>
</ui:composition>

我尝试显示带有服务器信息的数据表,并在弹出窗口中显示服务器的详细信息,但是当单击按钮时,服务器的详细信息未出现在弹出窗口中,我不知道如何设置在Bean中选择的服务器和在弹出窗口中显示.

I try to show a datatable with server info and show the details of a server in a popup, but when the button are clicked the details of server not appears in popup, i dont know how set the server selected in the bean and show it in the popup.

推荐答案

在Bean中存储服务器标识符(名称或ID)(请参阅

Store server identifier (name or id) in bean (see my answer) and reuse it in popup.

示例:

    <h:form id="notesForm">
        <rich:messages />

        <a4j:jsFunction name="selectRow" oncomplete="#{rich:component('noteDetails')}.show()"
            render="noteDetailsForm">
            <a4j:param name="noteId" assignTo="#{chNotesAction.currentNoteId}"
                converter="javax.faces.Long" />
        </a4j:jsFunction>

        <rich:dataTable id="noteTable" style="width: 100%"
            value="#{chNotesAction.notesList}" var="rs"
            rowClasses="oddrow, evenrow" columnClasses="nowrap,"
            rows="#{referenceData.recordsPerPage}" sortMode="single"
            onrowclick="selectRow('#{rs.noteLogId}')"
            rowKeyVar="currRow">

            <rich:column id="date">
                <f:facet name="header">
                    <h:outputText value="#{msg.entryDate}" />
                </f:facet>
                <h:outputText value="#{rs.changeDate}" />
            </rich:column>

            <rich:column>
                <f:facet name="header">
                    <h:outputText value="#{msg.notesType}" />
                </f:facet>
                <h:outputText value="#{rs.noteType}" />
            </rich:column>

            <f:facet name="footer">
                <rich:dataScroller renderIfSinglePage="false" for="noteTable"
                    stepControls="show" fastControls="hide" />
            </f:facet>
        </rich:dataTable>
    </h:form>

    <rich:popupPanel id="noteDetails" autosized="true">
        <f:facet name="header">
            <h:panelGroup>
                <center>
                    <h:outputText value="#{msg.noteTitle}" />
                </center>
            </h:panelGroup>
        </f:facet>
        <f:facet name="controls">
            <h:graphicImage value="/images/close.png" 
                style="cursor:pointer" onclick="#{rich:component('noteDetails')}.hide()" />
        </f:facet>
        <h:form id="noteDetailsForm">
            <rich:messages />

            <h:panelGrid columns="2" columnClasses="nowrap,">
                <h:outputText value="#{msg.notes}" />
                <h:inputTextarea value="#{chNoteForm.noteText}" label="#{msg.notes}"
                    rows="10" cols="50" style="resize:none;">
                    <f:validateLength maximum="4000" />
                </h:inputTextarea>

                <h:outputText value="#{msg.clientInitiated}" />
                <h:selectBooleanCheckbox value="#{chNoteForm.clientInitiated}" />
            </h:panelGrid>
        </h:form>
    </rich:popupPanel>

Bean部分:

    private Long currentNoteId;
    public void setCurrentNoteId(Long noteId) {
        this.currentNoteId = noteId;
        // setup popup related data here
        }
    }

这篇关于Richfaces:在弹出窗口中显示详细信息[命令按钮,操作和弹出窗口]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆