Re: Simple Javabean question
1) If you bean implements List then you could use myBean[0] in EL. public class MyBean implements List { public Object get(int i) { return getPair(i); } ... } 2) Or maybe have a property that implements List myBean.list[0]. public class MyBean { public List getList() { return new List() { public Object get(int i) { return getPair(i); } } ... } ... } At 11:43 15/10/2004 -0700, you wrote: I have a Javabean I've created that has setters and getters to an array: public String getPair(int idx) { return (pair[idx] == null ? : pair[idx]); } public void setPair(String[] var) { this.pair = var; } My problem is that I don't know how to access the index of the array w/JSTL. I can do a regular set and get with just one variable, but how do I access this an array index? I've looked all over! I tried this: jsp:useBean id=outlet class=com.OutletData scope=session/ c:set var=${sessionScope.outlet.pair[0]} value=Test/ to no avail. Thanks, - Nic. - 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]
Re: Simple Javabean question
PD: You can read http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html Chapter 12 Section Expression Language | Variables for learning how EL works in all cases. At 11:43 15/10/2004 -0700, you wrote: I have a Javabean I've created that has setters and getters to an array: public String getPair(int idx) { return (pair[idx] == null ? : pair[idx]); } public void setPair(String[] var) { this.pair = var; } My problem is that I don't know how to access the index of the array w/JSTL. I can do a regular set and get with just one variable, but how do I access this an array index? I've looked all over! I tried this: jsp:useBean id=outlet class=com.OutletData scope=session/ c:set var=${sessionScope.outlet.pair[0]} value=Test/ to no avail. Thanks, - Nic. - 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]
Re: Simple Javabean question
Great, thanks for the pointers. I read the area on EL and that helped, but I am still confused on the 'set' portion. How does the index *and* the value get passed to the setter? Using a list, I would need: list.set(i,var). Thanks again for the help, I know this is simple but I'm still trying to piece together how these work. - Nic. Helios Alonso wrote: 1) If you bean implements List then you could use myBean[0] in EL. public class MyBean implements List { public Object get(int i) { return getPair(i); } ... } 2) Or maybe have a property that implements List myBean.list[0]. public class MyBean { public List getList() { return new List() { public Object get(int i) { return getPair(i); } } ... } ... } At 11:43 15/10/2004 -0700, you wrote: I have a Javabean I've created that has setters and getters to an array: public String getPair(int idx) { return (pair[idx] == null ? : pair[idx]); } public void setPair(String[] var) { this.pair = var; } My problem is that I don't know how to access the index of the array w/JSTL. I can do a regular set and get with just one variable, but how do I access this an array index? I've looked all over! I tried this: jsp:useBean id=outlet class=com.OutletData scope=session/ c:set var=${sessionScope.outlet.pair[0]} value=Test/ to no avail. Thanks, - Nic. - 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]