You can simply create a bean implementing the Map interface. Then, in
the get(Object key) use introspection to locate the class referenced and
extract the given public field.
eg, get("some.package.Class.THE_FIELD") will do a
return
Class.forName("some.package.Class").someMethodAmTooLazyTooLookForInApi("THE_FIELD");
This should take no more than a few lines of code to create such bean
and you can even make it read/write :)
Reference this bean as an application bean, with a name like
'StaticAccessor' and use this in your JSF:
<h:inputHidden id="a"
value="#{StaticAccessor['com.jsportal.projectportal.web.webActions.login']}"/>
Note: use #{} and not ${} in JSF!!
JS Portal Support a écrit :
> Hi,
>
> Just started to implement Shale and JSF. As I've always worked more with
> scriptlets and Servlets I can't seem to figure out how to reference a public
> static value from one of my classes in my JSP's. I've always used:
>
> <input type="hidden" name="a"
> value="<%=com.jsportal.projectportal.web.webActions.login%>"/>
>
> Now I try to achieve this with the following:
>
> <h:inputHidden id="a"
> value="${com.jsportal.projectportal.web.webActions.login}"/>
>
> I understand this doesn't work as it will try to call
> com.getJsportal()....etc. But how do I do it, as the <%=%> is not allowed in
> these taglib tags?
>
> Thanks,
> Joost
>
>