Add Remove List Options
I have two pages.One for viewing all data.Second for editing that data.
The other edit page is in form format and all the fields get prepopulated with the data as they are bound by the request bean properties from the first view page.How can I set the same prepopulation of product-names in an add remove list. I want to set all those product-names as default selected from where I can add and can remove as desired.
The previous data for add remove list will be in this format->|A|B|C|
Now I want that A ,B and C products should be default selected on loading of the page.
The product names vary since they come from the view page.But there is a fixed number of products and all names are already known,the only thing is that they can be in any combinations which vary dynamically.
Please tell me some easy way for the same.
Thanks in advance.
[891 byte] By [
Sheen] at [2007-11-26 12:17:26]

# 2
If I understand the use-case correctly, you want the options selected from the addRemove component on page 1 to form the basis of the available options in the addRemove list on page 2.
The recommended method of transfering values from one page to another is via the RequestBean. In your case, I suggest adding two properties to the request bean. The first we'll call "pageOneAddedValues", and it will be of type java.lang.Object[]
. The second we'll call "pageTwoOptions", and it will be of type com.sun.rave.web.ui.model.Option[]
, and it should probably also be read-only. You bind the Selected property of the page 1 addRemove to the pageOneAddedValues property, and you bind the Items property of the page 2 addRemove to the pageTwoOptions property.
The trick is to use the values set the pageOneAddedValues property as the seed for the options returned by the pageTwoOptions property. Assuming the simplest case where the option labels are the same as the values, this can be simply:
public Option[] getPageTwoOptions() {
Object[] selectedValues = this.getPageOneAddedValues();
if (selectedValues == null)
return new Option[0];
Option[] options = new Option[selectedValues.length];
for (int i = 0; i < options.length; i++) {
options[i] = new Option(selectedValues[i]);
}
return options;
}
Good luck!
// Gregory
Message was edited by:
gjmurphy
Message was edited by:
gjmurphy