el

How to display value of List#size() in JSF EL?

爱⌒轻易说出口 提交于 2019-12-29 05:43:05
问题 I'd like to know if there's a way to bind the returned value of a method into a JSF component. I'll explain myself better. Let's say I have a class like this: public class Document { private List<Attachment> attachments; //getter and setter here } this class is exposed to jsf through a registered managed bean in a property called currentDocument, and used in a jsf this way <h:outputText value="#{myManagedBean.currentDocument.attachment.size}" /> This isn't correct, I know. But what is the

Upgrade JBoss 5.1 from EL 2.1 to EL 2.2?

China☆狼群 提交于 2019-12-29 05:36:45
问题 This question is quick and simple. JBoss 5.1 comes out of box supporting JSP and EL (Expression Language) 2.1 and Servlet 2.5. Is it possible to upgrade or hack this to use EL 2.2? UPDATE: I tried what BalusC's answer stated and got the following error: 2011-08-01 10:29:52,418 SEVERE [javax.enterprise.resource.webcontainer.jsf.config] (main) Unable to instantiate ExpressionFactory 'org.jboss.el.ExpressionFactoryImpl' 2011-08-01 10:29:52,441 SEVERE [javax.enterprise.resource.webcontainer.jsf

Is there a shorthand for <fmt:message key=“key” />?

北战南征 提交于 2019-12-29 03:29:06
问题 It's tedious and ugly to write things like: <input type="button" value="<fmt:message key="submitKey" />" /> And in case you want to nest the message tag in another tag's attribute it becomes even worse. Is there any shorthand for that. For example (like in JSF): <h:commandButton value="#{msg.shareKey}" /> (spring-mvc-only solutions applicable) 回答1: This feels like a bit of a hack, but you could write a custom implementation of java.util.Map which, when get(key) is called, fetches the message

How to HTML-encode in the JSP expression language?

左心房为你撑大大i 提交于 2019-12-28 16:44:33
问题 Consider the following piece of JSP: <param name="FlashVars" value="${flashVars}" /> The value of ${flashVars} contains ampersands and needs to be encoded before it is output. Instead, JSP expects the value of ${flashVars} to be a piece of HTML and outputs the ampersands verbatim, resulting in bad HTML. I found out that I can get the value to be encoded if I write it like this: <param name="FlashVars" value="<c:out value="${flashVars}"/>" /> But this looks really ugly and confuses my IDE to

javax.el.ELException: Failed to parse the expression [{pz:instanceof(object,'com.project.domain.MyClass')}]

廉价感情. 提交于 2019-12-28 16:02:48
问题 Currenty I have a web project with JSF 1.2 and Facelets running in tomcat 6.0.18.0. I decided to upgrade the servlet container, thus i deployed in tomcat 7 and all seemed ok until we hit one view using my custome facelet functions. javax.el.ELException: Failed to parse the expression [{pz:instanceof(object,'com.project.domain.MyClass')}] Caused by: org.apache.el.parser.ParseException: Encountered " ":" ": "" at line 1, column 5. Was expecting one of: "}" ... "." ... "[" ... This error occurs

JSF - actionListener tag calls method which doesn't take an ActionEvent parameter

时间秒杀一切 提交于 2019-12-28 07:05:07
问题 I keep reading posts which say that ActionListener methods must have the following signiture: public void calledByActionListener(ActionEvent e) { } Invoked like so: <p:commandButton value="Example" id="example" process="@this" ajax="false" actionListener="#{exampleBean.calledByActionListener()}"> However I have a no-arg method like this which works: public void calledByActionListener() { } Did something change? 回答1: Yes, that's the new EL 2.2 feature of invoking methods with custom arguments.

Javascript String.replace(/\$/,str) works weirdly in jsp file

戏子无情 提交于 2019-12-28 06:36:13
问题 For simplicity, i have the following file named test.jsp: <script language="javascript"> alert("a$b".replace(/\$/g,"k")); </script> I put this file in my local server, then display it using firefox: http://localhost:8080/myproj/test.jsp. It works okay, the result alert string is: akb But when i put this file in a remote server and use the same firefox to display, it output is: a$bk which is incorrect for me. Then i change the test.jsp content to: <script language="javascript"> alert("a$b"

How to output ${expression} in Freemarker without it being interpreted?

◇◆丶佛笑我妖孽 提交于 2019-12-28 05:32:04
问题 I'm trying to use Freemarker in conjunction with jQuery Templates. Both frameworks use dollar sign/curly brackets to identify expressions for substitution (or as they're called in freemarker, "interpolations") , e.g. ${person.name} . So when I define a jQuery Template with expressions in that syntax, Freemarker tries to interpret them (and fails). I've tried various combinations of escaping the ${ sequence to pass it through Freemarker to no avail - \${ , \$\{ , $\{ , etc. Inserting a

Escape JavaScript quotes in EL in a JSF component attribute

我的未来我决定 提交于 2019-12-28 04:34:05
问题 I have an onclick event that depends on the state of a variable. So I need to do something like onclick="#{object.isEnabled ? 'ch.my.js_method('#{object.property}'); return false;' : 'return false;'" The problem is, that I can't use ' inside of the onclick. How can I escape the quotes inside of the EL? 回答1: You can escape them with \ or \\ , but rules differ per EL implementation, because it isn't clear cut in EL spec (Oracle's EL impl needs single backslash, but Apache needs double backslash

How to concatenate Strings in EL expression?

≯℡__Kan透↙ 提交于 2019-12-27 12:24:58
问题 I need to create a callback for <h:commandButton> while as a parameter I need to pass an argument that is string-concatenated with an external parameter id: I tried nesting an EL expression something like this: <h:commandButton ... action="#{someController.doSomething('#{id}SomeTableId')}" /> However this failed with an EL exception. What is a right syntax/approach to do this? 回答1: If you're already on EL 3.0 (Java EE 7; WildFly, Tomcat 8, GlassFish 4, etc), then you could use the new +=