Hi Felippe,

Thank you for your fast reply. I have double checked with what you have
suggested. But the problem is still here. 

Regarding to the situation, the second list contains all the options
actually. If I show only the doubleselect box without default values to
show, all the options are there. And if I change the selection of fist
select box, the second one will change accordingly. This means the
doubleselect box is up and running well.

But the problem is I have default values to show when user see the
doubleselect box, and the default value for second list was not shown
correctly (some option is selected, but not the right one). 

For example, the first list contains countries, and second list contains
associated cities. E.g. UK list contains Edinburgh, Oxford, London,
etc.(in such order), and if the database stores a record with
country=UK, and City=London, the doubleselect list should display the
fist list as UK, and second list as London. But the problem is the first
list can show UK, while the second list show only the first one in the
tertiaryoptions list. As in this example, it shows Edinburgh - the fist
element of the second list. And it supposes to show London - the third
one of second list.. 

In this implementation, I have the action class contains identifier
variable, and associated getters and setters. In the JSP, I set the name
of doubleselect tag to be "%{'identifier.' + paramName}", so when the
page renders, the value in identifier variable can be shown directly on
the page. I have tested this with textfield, checkbox, select, etc. they
all worked fine to show default values, except the doubleselect tag. 

I wonder is anything wrong with my implementation, or doubleselect list
just don't have such ability? 

Another guess I had is the Javascript used in doubleselect tag. The
second select list is actually generated by javascript. This might be
the reason to cause above issues. May be I've been paranoid?

Anyway, I have been stuck with this issue for a long time now. Still
cant figure out why. Your help would be very much appreciated.

Thanks again Felippe,

Cheers,
Jipu

-----Original Message-----
From: Felippe Scheidt [mailto:[EMAIL PROTECTED] 
Sent: Monday, November 10, 2008 8:17 PM
To: Struts Users Mailing List
Subject: Re: HELP!!! DoubleSeclect tag with default values

Hi Jipu,

Well, if i understood correctly, the second list, "tertiaryoptions" is
been
completed with only one city, and there is another cities of course. The
doubleselect tag bind the two lists behind through ValueStack. For this
works correctly, verify the first list, "menu.menuoptions". This is
probably
a list of MenuOption. Verify if MenuOption contains a list of
tertiaryoptions, something like this:
public class Menuoption{
...
  List<TertiaryOption> tertiaryoptions;
...
}

This is a way to doubleselect binds this two collections.

Felippe.



On Mon, Nov 10, 2008 at 2:33 PM, Jipu Jiang <[EMAIL PROTECTED]>
wrote:

> Hi Felippe,
>
> Thank you so much for the response. Sure, here is the code:
>
> JSP:
>
> <s:form id="editRecordForm" action="updateRecord" theme="simple">
>        <table class="query-page-table">
>                <tr>
>                        <s:iterator value="sections" id="sec"
> status="secs">
>                                <table class="section-table">
>                                        <tr>
>                                                <td colspan="3">
>                                                        <h3>
>
> <s:property value="name" />
>                                                        </h3>
>                                                </td>
>                                        </tr>
>
>                                        <s:iterator value="parameters"
> id="para" status="paras">
>                                                <tr>
>                                                        <td
> class="parameter-label">
>
> <s:property value="label" />
>                                                        </td>
>                                                        <td>
>                                                                <s:if
> test="type == \"menu\"">
>
> <s:set name="menuoptions" value="menu.menuoptions"></s:set>
>
> <s:set name="tertiaryParamName"
value="menu.tertiaryParamName"></s:set>
>
> <s:if test="menu.tertiary == 1">
>
> <s:doubleselect name="%{'identifier.' + paramName}"
>
> headerKey="" headerValue="--- Please Select ---"
>
> list="menu.menuoptions" listKey="value" listValue="value"
>
> doubleId="%{'editRecordForm_identifier_' + menu.tertiaryParamName}"
>
> doubleName="%{'identifier.' + menu.tertiaryParamName}"
>
> doubleList="tertiaryoptions" doubleListKey="name"
>
> doubleListValue="name" />
>
> </s:if>
>
> <s:else>
>
> <s:select name="%{'identifier.' + paramName}"
>
> listKey="value" label="%{para.label}" list="menu.menuoptions"
>
> listValue="value" emptyOption="false" headerKey=""
>
> headerValue="--- Please Select ---" theme="simple" />
>
> </s:else>
>                                                                </s:if>
>                                                        </td>
>                                                </tr>
>
>                                        </s:iterator>
>                                </table>
>                        </s:iterator>
>                </tr>
>                <tr>
>                        <td colspan="3" align="right">
>                                <br />
>                                <s:submit value="Update Record"
> theme="simple"></s:submit>
>                                <s:reset theme="simple"></s:reset>
>                        </td>
>                </tr>
>        </table>
>
> </s:form>
>
>
------------------------------------------------------------------------
> Here is the updateRecordView Method in the UpdateRecordAction.java:
>
>        public String updateRecordView() throws Exception {
>                try {
>                        this.sections =
> this.parameterManager.getSections();
>                        this.identifier =
> this.identifierManager.getIdentifierByRegisterId(this.id);
>                        return SUCCESS;
>                } catch (CannotCreateTransactionException e) {
>                        log.error("CannotCreateTransactionException:
> Hibernate transaction exception!!! Timeout.");
>                        e.printStackTrace();
>                        return EXPIRE;
>                } catch (Exception e) {
>                        log.error("Exception caught in
> readRecordView()!!!");
>                        return ERROR;
>                }
>        }
>
>
> User access goes to updateRecordView action first, and fetch data from
> database. If successful, it goes to the jsp page to show the
parameters
> and associated values. But the doubleselect tag shows only the value
of
> fist select box, second box shows the first option in from the list,
not
> the one suppose to display.
>
> Any help would be much appreciated.
>
> Many thanks,
> Jipu
>
> -----Original Message-----
> From: Felippe Scheidt [mailto:[EMAIL PROTECTED]
> Sent: Monday, November 10, 2008 12:22 PM
> To: Struts Users Mailing List
> Subject: Re: HELP!!! DoubleSeclect tag with default values
>
> Can you paste your code please?
>
> Scheidt.
>
>
> On Mon, Nov 10, 2008 at 9:04 AM, Jipu Jiang <[EMAIL PROTECTED]>
> wrote:
>
> > Dear all,
> >
> > I was trying to display a JSP page with some parameters from the
> > database. Everything shows up perfectly except the second dropdown
> list
> > of the doubleselect tag, which should display the value from java
> action
> > but it always shows the first value of the second list.
> >
> > For example, the first list contains countries and the second list
> > contains cities. E.g. if I select UK from the first select box, the
> > second should be London, Birmingham, Edinburgh etc.
> >
> > Now the default values of the select boxes depend on what's in the
> > database. I can get the first select box to show UK, but the second
> one
> > always shows London, which is the first one in the second list.
> Instead,
> > it should show other cities based on values in database.
> >
> > I guess it's because of javascript. Does anyone know how to deal
with
> > such problem?
> >
> > Also, when I assign values to the doubleHeaderKey and
> doubleHeaderValue
> > of doubleselect tag, the second select box shows no header at all.
How
> > can I make this work?
> >
> > Many thanks in advance,
> > Jipu
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to