webtier@glassfish.java.net

Woodstock / AddRemoveList / prepopulate

From: <robert.hook_at_salmat.com.au>
Date: Fri, 21 Nov 2008 12:21:05 +1000

This is a problem I've been chasing for quite some time, but have only just returned to be able to examine in any detail, subsequent
to finding out that, yes, Project Woodstock is completely dead in the water, and rapidly sinking: I need to have a page which has an
AddRemoveList on it. The "selected" side of the list needs to be prepopulated. So you can visualise what I am talking about, this
current page is for editing a group of users. The "available" side of the list contains all the users not in the group, the
"selected" side is the users in the group. I have tried a great number of different approaches, and I cannot prepopulate the
"selected" side.

I just downloaded and installed NB 6.5, and built a dummy project containing nothing but a page with an AddRemoveList on it. I then
modified the prerender() method:

    public void prerender() {
        Option[] choices = new Option[3];
        for (int i = 0; i < choices.length; i++) {
            choices[i] = new Option("choice"+i, "choice"+i);
        }
        getAddRemoveList1DefaultOptions().setOptions(choices);

        String presel="option5";
        getAddRemoveList1DefaultOptions().setSelectedValue(presel);
        getAddRemoveList1().setValue(presel);
    }

and also tried this:

    public void prerender() {
        Option[] choices = new Option[3];
        for (int i = 0; i < choices.length; i++) {
            choices[i] = new Option("choice"+i, "choice"+i);
        }
        getAddRemoveList1DefaultOptions().setOptions(choices);

        String[] presel = new String[]{"choice4","choice5"};
        getAddRemoveList1DefaultOptions().setSelectedValue(presel);
        getAddRemoveList1().setValue(presel);
    }

The page paints with the control having "choice1".."choice3" in the "available" side, but the "selected" side remains empty. I will
be delving into the Woodstock code to track down what is going on (if I can work out which is the correct version of the code to
examine), but need some assurance that the approach I have taken above is correct.
-- 
Robert Hook | Software Engineer for Salmat BusinessForce
16 Archimedes Pl
Murarrie QLD 4172 Australia
t   +61 (07) 3896 0896
f   +61 (07) 3899 5674
m   +61 0407 959 570
e   robert.hook_at_salmat.com.au
w   salmat.com.au
***********************************************************************************
This e-mail, including any attachments to it, may contain confidential and/or personal information. If you have received this e-mail in error, you must not copy, distribute, or disclose it, use or take any action based on the information contained within it. Please notify the sender immediately by return e-mail of the error and then delete the original e-mail.
The information contained within this e-mail may be solely the opinion of the sender and may not necessarily reflect the position, beliefs or opinions of the organisation on any issue. This email has been swept for the presence of computer viruses known to the organisation’s anti-virus systems.
***********************************************************************************