-1

Please help me to find a example to update p:inputtext with data stored in a bean which is set(solved already) by selecting a row of a datatable of a p:dialog. I have succeeded updating outputtext in the same manner.

I am using (learning) netbeans 7.2 primefaces 3.2, glassfish 3.1

thansk for all your help

rs_ncs

4

3 回答 3

0

如果您想在从数据表中选择行时更新组件,则可以使用正在侦听事件update的 a 的属性。像这样的东西:<p:ajax>rowselect

<p:ajax event="rowSelect" update=":xx:xx" />
于 2012-12-11T10:35:00.920 回答
0

查看primefaces 展示用户指南,您会找到所需的一切;详细搜索数据表组件的 rowSelect 事件。祝你好运=)

于 2012-12-11T10:14:30.810 回答
0

正如 BalusC 所建议的,代码<p:ajax event="rowSelect" update=":xx:xx" />应该可以工作....

这是同时更新 inputtext 和 outputtext 的示例。

<h:form>
    <p:dataTable id="usertable" var="user" value="#{userManageBean.userList}"
        rowKey="#{user.U_ID}" selection="#{userManageBean.selectedUser}"
        selectionMode="single" paginator="true" rows="18" >



        <p:ajax event="rowSelect" update=":useredit:edituser" />
        <p:ajax event="rowSelect" update=":viewuser:displayuser" />



        <p:column headerText="User Name">
            <h:outputText value="#{user.username}" />
        </p:column>

        <p:column headerText="FName">
            <h:outputText value="#{user.firstname}" />
        </p:column>

        <p:column headerText="LName">
            <h:outputText value="#{user.lastname}" />
        </p:column>



    </p:dataTable>
</h:form>

<p:dialog id="userview" header="View User" widgetVar="dlg2" >

    <h:form id="viewuser">
        <h:panelGrid id="displayuser" columns="2" cellpadding="4">
            <h:outputText value="User Name:" />
            <h:outputText value="#{userManageBean.selectedUser.username}" />

            <h:outputText value="First Name" />
            <h:outputText value="#{userManageBean.selectedUser.firstname}" />

            <h:outputText value="Last Name:" />
            <h:outputText value="#{userManageBean.selectedUser.lastname}" />

        </h:panelGrid>
    </h:form>

</p:dialog>

<p:dialog id="user_edit" header="Edit User" widgetVar="dlgedit" >

    <h:form id="useredit">

        <h:panelGrid id="edituser" columns="2" cellpadding="4">

            <h:outputText value="First Name" />
            <h:inputText value="#{userManageBean.selectedUser.firstname}" />


            <h:outputText value="Last Name" />
            <h:inputText value="#{userManageBean.selectedUser.lastname}" />


            <p:commandButton id="updateUser" value="Add" action="#{someaction}"
                ajax="false" />


        </h:panelGrid>
    </h:form>
</p:dialog>
于 2013-01-04T12:54:55.650 回答