开发者

storing separate session variables for different SelectOneMenu(s) in a dataTable JSF

I have a dataTable which has a value of a bean class which looks like this:

public class myBean {
    private List<SelectItem> depList;

With getters and setters.

My getter calls a method buildDepList() which gets department names from the database and fills the depList.

Here's how my JSP file looks like:

<ice:dataTable id="specializationTable" style="height: 216px; left: 134px; top: 62px; position: absolute"
    value="#{AdmissionApplication$Application.specBean}" var="specRow" width="480">
    <ice:column id="column2">
        <ice:outputText id="outputText9" value="#{specRow.choiceNum}" visible="true"/>
        <f:facet name="header">
            <ice:outputText id="outputText3" value="#{msg.Choice_Number}"/>
        </f:facet>
    </ice:column>
    <ice:column id="column4">
        <f:facet name="header">
            <ice:outputText id="outputText8" v开发者_如何学运维alue="#{msg.Department}"/>
        </f:facet>
        <ice:selectOneMenu id="selectOneMenu2" partialSubmit="true" value="#{specRow.departmentName}">
            <f:selectItems id="selectOneMenu2selectItems" value="#{specRow.departmentItems}"/>
        </ice:selectOneMenu>
    </ice:column>
    <ice:column id="column5">
        <f:facet name="header">
            <ice:outputText id="outputText10" value="#{msg.Specialization}"/>
        </f:facet>
        <ice:selectOneMenu id="collegesSelectOneMenu" partialSubmit="true" style="width: 118px" value="#{specRow.specializationName}">
            <f:selectItems id="selectOneMenu3selectItems22" value="#{specRow.specializationItems}"/>
        </ice:selectOneMenu>
    </ice:column>
</ice:dataTable> -->

The value of the selectOneMenu (the String) should be in a session Bean, right?

myBean class is in fact application scoped. I have a list of this object List<myBean> called specBean as you can see in my JSP code where the dataTable value is set to that.

What do you suggest, should I have n different variables for the names of the selectOneMenu to save in the session? How do you suggest to do that?


The value of the selectOneMenu (the String) should be in a session Bean, right?

Depends. Putting it in a session scoped bean will cause any changes in the value to be reflected/influenced to/by multiple browser windows/tabs in the same session. This may cause unintuitive webapp behaviour and thus lead to bad user experience. A request scoped (or if you're already on JSF 2.0, view scoped) bean is a better choice.

myBean class is in fact application scoped. I have a list of this object List called specBean as you can see in my JSP code where the dataTable value is set to that.

What do you suggest, should I have n different variables for the names of the selectOneMenu to save in the session? How do you suggest to do that?

It's unclear what you're talking about here, but i and f the data is constant throughout the entire application and can be shared among different sessions/requests, such as the List<SelectItem> for f:selectItems, then it's indeed better to put it in an application scoped bean.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜