It seems your T class does not implement a correct comparison operator ...
Have you coorectly define the "equals" function ?

[EMAIL PROTECTED] a écrit :
Hello, In a page that display a query form and query results together, I want to remember the property selected by the user for the last query. I store this value in a page property, but I cannot get the PropertySelection to render using the previous value for the default value. It reverts to the value of index 0.
My current solution below use LabeledPropertySelectionModel and results in 
duplicate option in the pull-down.
Any help appreciated,
Alex./

from Search.html
           <tr>

             <td><strong><span key="po-component">PO 
Component</span></strong></td>

             <td><select jwcid="sg_po_component_filter">

                     <option value="0">****Select Label ****</option>

             </select></td>

           </tr>

from the Search.page
    <component id="sg_po_component_filter" type="PropertySelection">
        <binding name="model" value="possibleComponents"/>
        <binding name="value" value="poComponent"/>
    </component>

public abstract class SearchPage extends BasePage implements 
PageBeginRenderListener {

    @Persist("session")
    public abstract Component getPoComponent();
    public abstract void      setPoComponent(Component poComponent);
    public abstract IPropertySelectionModel getPossibleComponents();
    public abstract void                    
setPossibleComponents(IPropertySelectionModel model);

    public void pageBeginRender(PageEvent event) {
        if (getPoComponent() != null)
setPossibleComponents(new LabeledPropertySelectionModel(getPossibleComponents(), getPoComponent().getName(), getPoComponent()));
       }
}

public class SelectionModel<T extends Option> implements 
IPropertySelectionModel, Serializable {
     private static final long serialVersionUID = 1L;
    private List<T> options;
        this.options = new ArrayList<T>();
        for (T obj: options) {
            this.options.add(obj);
        }
    }
public int getOptionCount() {
        return options.size()+1;
    }

    public Object getOption(int index) {
        return getOptionObj(index);
    }
    public String getLabel(int index) {
        return getOptionObj(index).getName();
    }
    public String getValue(int index) {
        return getOptionObj(index).getCode();
    }
    public Object translateValue(String value) {
for (T obj : options) if (obj.getCode().equals(value))
                return obj;
        return null;
    }
}

    private Option getOptionObj(int index) {
        return (Option) options.get(index);
    }



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


--
Stéphane Decleire

05 56 57 99 20
06 63 78 69 06

Reply via email to