Inject c:forEach iteration variable in seam component (JSP 2.1, JSF 1.2, JSTL 1.2)
viviansteller.vivian.steller.uni-ulm.de Apr 5, 2008 4:04 PMHi all,
I've problems getting the iteration variable (the var from JSTLs c:forEach) injected into a seam component using JSP as view technology.
First, the scenario:
- Seam 2.0.1.CR1
- JSP 2.1 (!)
- JSTL 1.2 (provided by container)
My application Server is JBoss AS 4.2.0.
Now, some source code:
JSP file:
<?xml version="1.0" encoding="UTF-8"?> <jsp:root version="2.1" xmlns="http://www.w3.org/1999/xhtml" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:c="http://java.sun.com/jsp/jstl/core"> ... <c:forEach items="#{lecturesView.languageSectors}" var="languageSector"> ... <c:forEach items="#{lecturesView.lectures}" var="lecture"> ... </c:forEach> ... </c:forEach> ... </jsp:root>
Seam Component
@Name("lecturesView") @Scope(ScopeType.STATELESS) public class LecturesViewHelper { ... @In(value="#{languageSector}", required=false) @Out(required=false) LanguageSector languageSector; public List<LanguageSector> getLanguageSectors() { return languageSectorAgent.findAll(); } public List<Lecture> getLectures() { return lectureAgent.listLectures(languageSector); } ... }
I'd expect that the var languageSector in the JSP c:forEach is exposed to the ELContext's VariableMapper (see item 1. in http://jcp.org/aboutJava/communityprocess/maintenance/jsr052/jstl-12-mr-changeLogPFD.html, I'm not 100% sure if JBoss AS's JSTL implementation does this, but it basically implements JSTL 1.2, that's for sure).
However, the problem is that I can't access this variable in my seam component (from within the getLectures() method), neither by injecting it as in the source code above nor by resolving the variable explicitely using (in Eclipse Debugger):
javax.faces.context.FacesContext.getCurrentInstance(). getELContext().getVariableMapper().resolveVariable("languageSector");
Isn't that supposed to work? That should have been be the aim of JSTL 1.2, right? Are there other ways to lookup the value? E.g. by accessing the JSP page
context? It seems that the JSP ELContext/VariableMapper (i.e. pageContext.getELContext()) is not the same instance as the one accessed by the code snippet above (even if they both are accessed in the same thread)?
I'm asking this list since I'm not sure if there is a much nicer approach to achieve the same (?) or if this a JBoss EL (2.0.1.GA) issue?
Thanks for any comments!