el

Make JSF access a Map<String, ?> values from an EL instead of a bean fields?

≡放荡痞女 提交于 2019-12-05 07:10:57
Is there any proper way to override the way JSF accesses the beans fields from an Expression Language? The idea is to mimic this behavior in order to access a Map<String, ?> values, where the bean fields would be the map keys. In other words, is it possible anyhow to use #{beanContainingNestedMap.keyOfSaidNestedMap} , just as if keyOfSaidNestedMap were a field of the beanContainingNestedMap ? If not, what other solution may I have? Example: Holder.java public class Holder { private Map<String, Object> objects = new HashMap<String, Object>(); public void add(String key, Object value) { objects

JSTL Session Lookup - Key Has Periods

◇◆丶佛笑我妖孽 提交于 2019-12-05 05:28:50
I am working with some legacy code, and at some point there is a key in the session that is something like session.setAttribute("com.org.something.Object",someObject); Now trying to access this in a jsp using jstl is a bit difficult becuase if I tried it like I normally would I would do: ${sessionScope.com.org.something.Object.someFieldGetter} As most of us can imagine it will fail because there is no com object in session scope. I also tried ${sessionScope.'com.org.something.Object'.someFieldGetter} And a parsing error was thrown. Does anyone know how to resolve this so that I can correctly

Why does JSF put String values in a Map<…, Integer>? And how to work around it?

时间秒杀一切 提交于 2019-12-05 04:42:49
问题 At first I got some ClassCastExceptions. When I went to the source, I found out that the values in my Map<Integer,Integer> were in fact Strings. I did the following experiment to check if the use of PrimeFaces was my problem: <h:form> <p:spinner value="#{testBean.integer}" /> <h:inputText value="#{testBean.integer}" /> <p:spinner value="#{testBean.mapInt[0]}" /> <h:inputText pt:type="number" value="#{testBean.mapInt[1]}" /> <p:commandButton value="Read Map Values" action="#{testBean

JSP comparison operator behaviour

天涯浪子 提交于 2019-12-05 04:17:31
I want to compare two different types in <c:if> tag of JSP. Basically left one is Number always but right one is a String and If that string could be parse to a Number I receive no error but If the String cant be parsed to a Number I receive javax.el.ELException: Cannot convert No of type class java.lang.String to class java.lang.Long . Practically: ${1 =="" } //works fine ${1 =="4" } //works fine ${1 =="Yes" } //triggers the Exception. But even the 3rd comparison worked fine in previous versions of JSPs but now it causes exceptions. Has the behaviour of == changed over period of time? Any

Java keywords not allowed as EL identifiers

谁都会走 提交于 2019-12-05 03:18:37
Recently I upgraded my development tomcat from 7.0.0 to 7.0.4. I had things like: <c:set var="static" value=".." /> <c:set var="class" value=".." /> Both worked on 7.0.0 but stopped working on 7.0.4. I opened a bug , it was closed, with the answer that: In and of itself, that tag will compile. The checks for Java identifiers were added to the EL processing so I suspect you have some illegal EL elsewhere on the page. This didn't sound quite clear, but I didn't get a subsequent answer, so I looked at the EL spec. For the JSP 2.1 (the latest being 2.2) I found that: Chapter 1, page 21: An

Guice - Inject dependency into a class with static helper methods

穿精又带淫゛_ 提交于 2019-12-05 02:56:58
I'm still new to Guice and haven't used any DI frameworks before. After reading the official wiki and many other documents I'm still unable to wrap my head around it completely. In my particular case I want to write a EL taglib function that uses some other (to-be-injected) class. As all taglib functions have to be declared as static, I can't just @Inject my dependency via constructor or setter. I thought of using the requestStaticInjection() method described in http://code.google.com/p/google-guice/wiki/Injections#Static_Injections but I unable to get it to work and haven't been able to find

Managed property value not updated when both beans are of same scope

随声附和 提交于 2019-12-04 17:45:04
I am seeing this strange behavior when using @ManagedProperty . I have 2 beans: UserManager (SessionScoped) @ManagedBean @SessionScoped public class UserManager extends BaseBean implements Serializable { private static final long serialVersionUID = 1861000957282002416L; private User currentUser; public String login() { // set value of currentUser after authentication } public User getCurrentUser() { return currentUser; } public boolean isLoggedIn() { return getCurrentUser() != null; } } CartBean ( ALSO SessionScoped) ... import javax.faces.bean.ManagedProperty; ... @ManagedBean @SessionScoped

EL expression: passing null as value of BigDecimal field

心已入冬 提交于 2019-12-04 17:15:19
I have class with BigDecimal property. When I bind to it EL expression and passing null - valueExpression.set(context, null) , new value of property becomes to be BigDecimal.ZERO . Is there any way to pass null to BigDecimal field without converting it to zero? You seem to be running Tomcat of at least version 6.0.16 or a fork of it like JBoss AS. Tomcat's builtin Apache EL parser will indeed do that for all classes extending Number . You need to add the following VM argument to disable this behaviour (which is indeed unintuitive, but unfortunately strictly as per the EL spec): -Dorg.apache.el

ui:composition template=“<template from jar>”

穿精又带淫゛_ 提交于 2019-12-04 16:45:42
I would like to place the Facelets template file for JSF in a JAR file. I tried to reference it by EL as <ui:composition template="#{resource['templates:template_pe_layout.xhtml']}"> which works perfect for CSS or images, but not for the composition template. How could I achieve the goal? BalusC The #{resource} expression is initially designed for use inside CSS files only like so .someclass { background-image: url(#{resource['somelibrary:img/some.png']}); } It's not intented for usage in <h:outputStylesheet> , <h:outputScript> or <h:graphicImage> which should rather be used as follows: <h

Target Unreachable, identifier resolved to null JSF 2.2 [closed]

北战南征 提交于 2019-12-04 15:45:31
I looked already those: Target Unreachable, identifier resolved to null in JSF 2.2 "Target Unreachable, identifier 'authenticator' resolved to null" in SEAM Java EE 6: Target Unreachable, identifier 'helloBean' resolved to null Target Unreachable, identifier "Bean Name" resolved to null Target Unreachable, identifier "Bean Name" resolved to null JSF: /index.xhtml @12,80 value="#{LoginBean.username}": Target Unreachable, identifier 'LoginBean' resolved to null http://www.coderanch.com/t/598907/JSF/java/Target-unreachable-identifier-resolved-null but none of them worked for me. Login.xhtml: <