array of UI component

I am trying to use an array of DropDown components like this jsp code (vwp project)

<ui:dropDown binding="#{scheduler.subjectDD[0]}" id="subjectDD1" items="#{scheduler.dropDown1DefaultOptions.options}"/>

the java bean contains

private DropDown subjectDD[] = new DropDown[10];

//initialized in the constructor

public DropDown getSubjectDD(int i) {

return this.subjectDD;

}

public void setSubjectDD(DropDown dd,int i) {

this.subjectDD=dd;

}

I am getting this error

javax.faces.el.PropertyNotFoundException: Error getting property 'subjectDD' from bean of type secsched.scheduler

at com.sun.faces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:127)

at com.sun.rave.web.ui.faces.UIComponentPropertyResolver.getValue(UIComponentPrope rtyResolver.java:84)

at com.sun.rave.web.ui.faces.DataProviderPropertyResolver.getValue(DataProviderPro pertyResolver.java:150)

at com.sun.rave.faces.data.ResultSetPropertyResolver.getValue(ResultSetPropertyRes olver.java:67)

seems like its execuing

public Object getValue(Object base, Object property)

when it should be executing (i think)

public Object getValue(Object base, int index)

please help

[1298 byte] By [java.bossa] at [2007-11-26 16:10:23]
# 1

I don't understand your idea for indexing a ui component. Nevertheless here are some corections:

- --

public DropDown getSubjectDD(int i) {

return this.subjectDD;

}

Try this instead

/**

* Indexed getter for property subjectDD.

* @param index Index of the property.

* @return Value of the property at <CODE>index</CODE>.

*/

public DropDown getSubjectDD(int index) {

return this.subjectDD[index];

}

- --

public void setSubjectDD(DropDown dd,int i) {

this.subjectDD=dd;

}

Try this instead

/**

* Indexed setter for property subjectDD.

* @param index Index of the property.

* @param subjectDD New value of the property at <CODE>index</CODE>.

*/

public void setSubjectDD(int index, DropDown subjectDD) {

this.subjectDD[index] = subjectDD;

}

cokneylonesoftneera at 2007-7-8 22:32:48 > top of Java-index,Development Tools,Java Tools...
# 2

thank you for your reply. actully i used the same code u did, i just mistakenly pasted the wrong code here :( ... any ways this code gives error

i created a new project for testing ... blow is the code

[[ the idea for using index is .. as i have 20 dropdown of the same kind i dont wanna write 20 get ... i rather just loop over it and get the value ....

seems like i cant make it work ... someone please help ...

any ways here is the code ...

<ui:form binding="#{Page1.form1}" id="form1">

<ui:dropDown binding="#{Page1.dropDown[0]}" id="dropDown1" items="#{Page1.dropDown1DefaultOptions.options}" />

</ui:form>

private DropDown dropDown[] = new DropDown[10];

///initialize in the init() section

public DropDown getDropDown(int i){

return this.dropDown;

}

public void setDropDown(DropDown dd, int i){

this.dropDown=dd;

}

--

the error i get is ... seems like

insted of executing ResultSetPropertyResolver.getValue(Object base, int index)

ResultSetPropertyResolver.getValue(Object base, Object property)

its executing

SEVERE: Servlet.service() for servlet jsp threw exception

javax.faces.el.PropertyNotFoundException: Error getting property 'dropDown' from bean of type webapplication4.Page1

at com.sun.faces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:127)

at com.sun.rave.web.ui.faces.UIComponentPropertyResolver.getValue(UIComponentPrope rtyResolver.java:84)

at com.sun.rave.web.ui.faces.DataProviderPropertyResolver.getValue(DataProviderPro pertyResolver.java:150)

at com.sun.rave.faces.data.ResultSetPropertyResolver.getValue(ResultSetPropertyRes olver.java:67)

at com.sun.faces.el.impl.ArraySuffix.evaluate(ArraySuffix.java:187)

java.bossa at 2007-7-8 22:32:48 > top of Java-index,Development Tools,Java Tools...