el

How to write a hardcoded string value inside EL expression #{ } in JSF?

人盡茶涼 提交于 2019-12-20 03:43:07
问题 I am trying to do the following: rendered="#{billBean.company.equals("something")}" But the problem is I cannot write "something" inside #{} . It causes the below XML parsing error: Element type "h:commandLink" must be followed by either attribute specifications, ">" or "/>". How can I achieve this? 回答1: Use single quote (') to refer to a plain String inside EL: rendered="#{billBean.company.equals('something')}" 来源: https://stackoverflow.com/questions/17772791/how-to-write-a-hardcoded-string

How to write a hardcoded string value inside EL expression #{ } in JSF?

笑着哭i 提交于 2019-12-20 03:43:03
问题 I am trying to do the following: rendered="#{billBean.company.equals("something")}" But the problem is I cannot write "something" inside #{} . It causes the below XML parsing error: Element type "h:commandLink" must be followed by either attribute specifications, ">" or "/>". How can I achieve this? 回答1: Use single quote (') to refer to a plain String inside EL: rendered="#{billBean.company.equals('something')}" 来源: https://stackoverflow.com/questions/17772791/how-to-write-a-hardcoded-string

How to get ID of calling component in the getter method?

为君一笑 提交于 2019-12-20 03:19:17
问题 Given the following example: <h:inputText id="foo" size="#{configBean.size}" /> I would like to get the id of the calling component foo in the getter method so that I can return the size from a properties file by a key of foo.length . public int getSize() { String componentId = "foo"; // Hardcoded, but I should be able to get the id somehow int size = variableConfig.getSizeFor(componentId); return size; } How can I achieve this? 回答1: Since JSF 2.0, there's a new implicit EL variable in the

Can JSP EL do direct attribute access

心已入冬 提交于 2019-12-20 02:39:40
问题 This really surprised me ! I have the following code in my JSP. <c:param name="title" value="${slideShow.title}" /> This code was working till I refactored the SlideShow class and made all attributes public and removed getters/setters. So it seems to me that EL works only with getter and not direct attribute access. Is this true ? Is there any way to get it to work with direct attributes instead of going through getters ? 回答1: JSP EL relies strictly on Java Bean specification, so it cannot

org.apache.jasper.JasperException: The function split must be used with a prefix when a default namespace is not specified

放肆的年华 提交于 2019-12-19 09:24:26
问题 the follwong exception is thrown while calling 1st page of my application org.apache.jasper.JasperException: /WEB-INF/login.jsp(28,21) The function split must be used with a prefix when a default namespace is not specified org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148) org.apache.jasper.compiler

How to configure Maven pom for Tomcat 7 with JSF 2.0 and EL 2.2?

百般思念 提交于 2019-12-19 09:17:26
问题 i want to use EL 2.2 for JSF 2 application and tomcat 7 is provided with EL 2.2 and i am confused about the following: 1- Should i provide the servlet-api , jsp-api and the EL in my pom file (using maven) as provided or don't include them at all in the pom file, since they are provided by container, what's the difference ? <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>3.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax

Whats the difference between “${foo.bar}” and “#{foo.bar}”?

落花浮王杯 提交于 2019-12-19 09:06:05
问题 I can use objects from my Java Beans within .jsp files by using the Expression Language (EL). Therefore I can get my value by typing ${foo.bar}. But I can also use #{foo.bar}. Can anybody explain the difference or provide a link with meaningful information? 回答1: #{foo.bar} syntax is from the JSF expression language. Some bright spark thought it would be a good idea to use a different syntax to JSP EL (i.e. ${foo.bar} ). I think some JSP containers are tolerant of this cockup, and let you use

Using varargs in a Tag Library Descriptor

血红的双手。 提交于 2019-12-19 05:33:28
问题 Is it possible to have a TLD map to the following function: public static <T> T[] toArray(T... stuff) { return stuff; } So that I can do: <c:forEach items="${my:toArray('a', 'b', 'c')}"... I tried the following <function-signature> s java.lang.Object toArray( java.lang.Object... ) java.lang.Object[] toArray( java.lang.Object[] ) And others but nothing seems to work. 回答1: Unfortunately that's not possible. The EL resolver immediately interprets the commas in the function as separate arguments

Using varargs in a Tag Library Descriptor

ぐ巨炮叔叔 提交于 2019-12-19 05:33:05
问题 Is it possible to have a TLD map to the following function: public static <T> T[] toArray(T... stuff) { return stuff; } So that I can do: <c:forEach items="${my:toArray('a', 'b', 'c')}"... I tried the following <function-signature> s java.lang.Object toArray( java.lang.Object... ) java.lang.Object[] toArray( java.lang.Object[] ) And others but nothing seems to work. 回答1: Unfortunately that's not possible. The EL resolver immediately interprets the commas in the function as separate arguments

How to use EL conditional operator in JSF component attribute?

倾然丶 夕夏残阳落幕 提交于 2019-12-19 04:09:22
问题 I need to dynamically choose the width of a <p:panelGrid> based on a backing bean property. However it is not working for me. I have a feeling that I have some syntax error in my code. <p:panelGrid style="width:#{myBean.fromCCRM} ?70%:90%"> ... </p:panelGrid> 回答1: The entire statement needs to go inside #{...} . style="width:#{myBean.fromCCRM ? '70%' : '90%'}" 来源: https://stackoverflow.com/questions/12292397/how-to-use-el-conditional-operator-in-jsf-component-attribute