JSF? accessing String array elements in JSF/JSP/Managed Bean

In struts you can do the following:

In the bean

private String strAry[] = { "FAM_1.JPG", "FAM_2.JPG", "FAM_2.JPG" };

public String getStringIndexed(int index) {

return strAry[index];

}

public void setStringIndexed(int index, String value) {

strAry[index] = value;

}

}

In the jsp:

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<jsp:useBean id="bean" class="org.apache.struts.webapp.exercise.StringBean"/>

<bean:write name="bean" property="stringIndexed[1]"/>

I've tried to do the same thing in JSF without success.

How can I access something similar to this

<h:graphicImage value="#{ThumbBean.stringIndexed[0]}" alt="No Image"/>

[772 byte] By [douglasmhursta] at [2007-10-2 3:28:36]
# 1

Since JSF 1.2/EL 2.1/JSP 2.1 :

If your stringIndexed is an array type property of the ThumbBean, you can access its element

from EL provided that you have:

public String getStringIndexd(int index){

return stringIndexed[index];

}

in your bean class code.

hiwaa at 2007-7-15 22:38:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Oh, no> getStringIndexd(int index){getStringIndexed(int index){
hiwaa at 2007-7-15 22:38:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Thanks for your response. I had that piece of code in my bean. My question was more how I access it from the jsp.

<h:graphicImage value="#{ThumbBean.stringIndexed[0]}" alt="No Image"/>

The line above was not working. The exception was that this was not a property of the bean.

douglasmhursta at 2007-7-15 22:38:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
REMINDER: This is JSF enviornment I'm working in here, not struts.I've searched Google high and low and have been able to find nothing on this with regard to JSF.
douglasmhursta at 2007-7-15 22:38:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

I dunno about arrays but I know you can use similar expressions with Maps:private Map<String, String> map;

public Map<String, String> getData() {

return map;

}

value="#{bean.map['key']}"

Looma at 2007-7-15 22:38:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

> Thanks for your response. I had that piece of code in my bean. My question was more

> how I access it from the jsp.

>

> <h:graphicImage value="#{ThumbBean.stringIndexed[0]}" alt="No Image"/>

>

> The line above was not working. The exception was that this was not a property of the bean.

>

> -

>

> REMINDER: This is JSF enviornment I'm working in here, not struts.

>

> I've searched Google high and low and have been able to find nothing on this with

> regard to JSF.

Read my first reply and use a JSF 1.2/EL 2.1/JSP 2.1 implementation.

Array indexing for bean property from JSF EL works just fine on them.

hiwaa at 2007-7-15 22:38:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...