tags:

views:

17

answers:

1

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" value="#{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?

A: 

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.

BalusC
I appreciate your help man. I am sorry I didn't make myself clear enough in the second part of the question! Anyways, I am wondering now if you have a tutorial on your blog (or know about any other tutorial) about using valueChangeListener with SelectOneMenu to change another SelectOneMenu.thanks again
Saher
Yes, I have one: http://balusc.blogspot.com/2007/10/populate-child-menus.html However, I consider this code is pretty nasty as this submits the form to the server on every change. Nowadays, it can be done better with help of ajaxical powers. You seem to be using IceFaces, I'd just take benefit of its ajaxical powers. I don't have hands on experience with it, so no more detail from me sorry.
BalusC