在运行时根据某些条件设置JSF 2.0中的下拉值

时间:2012-12-01 10:50:08

标签: jsf primefaces

我正在尝试在primefaces JSF中的下拉框中设置值。我有一个数据表,其中数据来自数据库,选择一行后我需要检查一列的值,并根据我需要设置下拉值。在下拉框中有两个值,它们是也来自数据库..我只需要根据数据表列值设置一个值。

我的数据表代码

<p:dataTable var="patient"  value="#{patientNotes.patientNote}"
                        scrollable="true" scrollHeight="262" rowKey="#{patient.id}"
                        styleClass="mygrid" paginator="true" rows="10"
                        paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                        currentPageReportTemplate="(Displaying {startRecord} - {endRecord} of {totalRecords}, Page: {currentPage}/{totalPages})"
                        paginatorPosition="bottom" rowsPerPageTemplate="5,10,15"
                        selection="#{patientNotes.selectedNotes}" selectionMode="single">

                        <p:ajax event="rowSelect" listener="#{patientNotes.onRowSelect}"  />
                        <p:column style="text-align: center" width="180">
                            <f:facet name="header">
                                <h:outputText value="Type" />
                            </f:facet>
                            <h:graphicImage value="../../images/dialog-warning.png" rendered="#{patient.warning == 'Y'}"/>
                            <h:graphicImage  value ="../../images/alert.jpg" rendered="#{patient.alert == 'Y'}" />
                            <h:graphicImage value = "../../images/transaction_flat_16.gif"  rendered="#{patient.creditControl == 'Y'}" />
                        </p:column>
                        <p:column headerText="Note" width="180">

                            <h:outputText value="#{patient.note}" ></h:outputText>
                        </p:column>
                        <p:column headerText="Created By" width="180">

                            <h:outputText value="#{patient.createdBy}"></h:outputText>
                        </p:column>
                        <p:column headerText="Date" width="180">
                            <h:outputText value="#{patient.date}"></h:outputText>
                        </p:column>


                    </p:dataTable>

在这里选择行我需要检查一个变量警报如果是“Y”我需要在下拉框中设置警告否则管理员..而这两个值ALERT和管理员都在来自数据库的下拉框中我只是需要设置它们。

下拉代码

<h:panelGroup layout="block" class="inputContainer3" id="paneltype">
                    <span>Type: </span>
                    <h:selectOneMenu value="#{addNotes.typeSelection}" id="menutype">
                        <f:selectItem itemLabel=""
                            itemValue="1" />
                        <f:selectItems value="#{addNotes.selectedType}" />
                    </h:selectOneMenu>
                </h:panelGroup>

请帮助我,如果你有更多的代码,请告诉我没有

提前致谢

0 个答案:

没有答案