【问题标题】:Passing Selected Row in Data Table to Another State in Spring Web-Flow在 Spring Web-Flow 中将数据表中的选定行传递给另一个状态
【发布时间】:2014-07-14 21:49:04
【问题描述】:

我无法用我有限的 Spring_flow 知识来解决这个问题。这是我的两个视图状态。

    <view-state id="viewPatientState" view="viewPatient.xhtml" model="patient">
    <transition on="newPatient" to="addPatient" />
    <transition on="viewPatient" to="viewPatientState" />
    <transition on="viewPatientProfile" to="patientProfile">

    </transition>

</view-state>

<view-state id="patientProfile" view="patientProfile.xhtml" model="patient">
    <transition on="newPatient" to="addPatient" />
    <transition on="viewPatient" to="viewPatientState" />

</view-state>

我想从 viewPatient 将患者对象或只是一个 id(整数)发送到 patientProfile。这是我的 viewPatient.xhtml。我只想传递所选行的 id 或所选对象。

<p:dataTable id="tbl" var="pat"
            value="#{patientService.getAllPatients()}" paginator="true"
            rows="10">

            <p:column>
                <f:facet name="header">
                    <h:outputText value="Hasta No" />
                </f:facet>
                <h:outputText value="#{pat.patientId}" />
            </p:column>

            <p:column exportable="false">
                <f:facet name="header">
                    <h:outputText value="Soyisim" />
                </f:facet>
                <h:outputText value="#{pat.lastName}" />
            </p:column>

            <p:column>
                <f:facet name="header">
                    <h:outputText value="İsim" />
                </f:facet>
                <h:outputText value="#{pat.firstName}" />
            </p:column>

            <p:column exportable="false">
                <f:facet name="header">
                    <h:outputText value="Yaş" />
                </f:facet>
                <h:outputText value="#{pat.age}" />
            </p:column>

            <p:column exportable="false">
                <f:facet name="header">
                    <f:facet name="header">
                        <h:outputText value="Profil" />
                    </f:facet>
                </f:facet>
                <p:commandLink id="profileLink" action="viewPatientProfile"
                    ajax="false">
                    <h:outputText value="Detay" />
                </p:commandLink>
            </p:column>
        </p:dataTable>

【问题讨论】:

    标签: jsf spring-mvc spring-webflow


    【解决方案1】:

    您在视图状态定义中使用“患者”作为模型。只需在 Patient 类中添加一个字段,说 selectedPatientId 并在视图中引用它。 我相信您的“患者”模型在流量镜中。如果它在 flowscope 中,它将保留用户选择。当您从视图“viewPatientState”导航到视图“patientProfile”时。

        public class Patient implements Serializable{
            public String selectedPatientId;
            ...
            //setters and getters
        }
    

    您可以找到有关作用域变量here 的更多详细信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-24
      • 1970-01-01
      • 2019-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-24
      • 1970-01-01
      相关资源
      最近更新 更多