el

jsp how to get base url cleanly without javascript

╄→гoц情女王★ 提交于 2019-12-24 02:19:11
问题 I'm trying to get the base url (for example: https://stackoverflow.com/) without using javascript. But there seem to be a lot of ways to split it off from https://stackoverflow.com/questions/ask so I was wondering what the cleanest way was (or if there's a preferred method). jstl functions would probably do the trick, but I'd like it to be as dynamically as possible, so I wouldn't have to change it if the /questions/ part was to change to let's say /question/. ${pageContext.request.scheme}://

#{facesContext} EL expression not resolved at runtime

僤鯓⒐⒋嵵緔 提交于 2019-12-23 19:38:03
问题 I am working on JSF 1.x On an example stated in JavaServer Faces in Action. My EL expression of 'Faces Context' is not executing at run time in command button on retrieving the image. My Project Structure is as follows: I have not used any Java code in this example, And it contains only one Login Page. The login.jsp is as follows: <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <f:view> <html> <head> <link rel="stylesheet"

JSF2 composite cc.attrs expression does not evaluate action parameters correctly

蹲街弑〆低调 提交于 2019-12-23 19:11:59
问题 I have a JSF composite component which is a list of email addresses that can be dynamically added to, and deleted from: <composite:interface shortDescription="Display party email addresses"> <composite:attribute name="addressable" required="true"/> </composite:interface> <composite:implementation> <h:panelGroup layout="block" id="emails"> <h:dataTable id="emailList" value="#{cc.attrs.addressable.emailAddresses}" var="email" styleClass="data-list small-list" cellpadding="0" cellspacing="0"> <h

CDI injection in a JSP

馋奶兔 提交于 2019-12-23 11:46:09
问题 Within a JSP it is possible to use CDI managed beans using EL expressions such as ${myBean.myAttribute}. No problem here. I would like to use "regular injection" (i.e. without using EL expressions) with @Inject in JSP files, for example : <%! @Inject MyBean myBean; %> then later <%= myBean.getMyAttribute() %>. Even if that example can be achieved using EL expressions, some other use cases cannot. This does not seem to be completely supported by app servers: - JBoss 6.0.0, JBoss 6.1.0, Resin 4

EL evaluation in a JSF page is not sequential

霸气de小男生 提交于 2019-12-23 06:04:55
问题 I have an XHTML with ui:composition tag which I am loading on AJAX. I am using a jQuery Ajax GET to load the URL of this XHTML. In the loaded page, I have an EL expression and after that I am also including another source which has a few more EL expressions. invariably, the EL expressions of the included source are being evaluated earlier than the one appearing before it. Some.xhtml <ui:composition ... #{relationshipAction.followMember(param['relateToProfile'])} <ui:include src="someOther

jsf 2 method parameters action listener

白昼怎懂夜的黑 提交于 2019-12-23 04:13:20
问题 Is there a way to pass a variable into a method param: <h:commandButton value="Add to Order" actionListener="#{orderBasket.addItems(currentItem.id)}"/> This always seems to pass 0 into the method for some reason. 回答1: That's only possible when you use action instead of actionListener <h:commandButton value="Add to Order" action="#{orderBasket.addItems(currentItem.id)}"/> and you're running a Servlet 3.0 / EL 2.2 capable container (Tomcat 7, Glassfish 3, JBoss 6, etc) and your web.xml is

Evaluating a Struts value within a JSTL tag

↘锁芯ラ 提交于 2019-12-23 02:57:13
问题 I'm currently developing a language pack for an application built on Struts 2. The language pack is defined in a properties file which will be accessed by the frontend JSP via JSTL (FMT tags). I'm trying to achieve something like String formatting, i.e. inserting a Struts value into a sentence string retrieved via an FMT tag. What's defined in my properties file: userprofile.link.text = <a href="{0}">Click here</a> to view your profile page. And from the JSP side, <fmt:message key=

JSF: How to replace “\\” in a string

人走茶凉 提交于 2019-12-23 00:45:07
问题 Suppose I have the string text\\ , I need to replace \\ with / . I tried the following expression: /* str = "text\\" */ <h:outputText value="#{fn:replace(str, '\\', '/')}" /> But I always run into the following exception: Caused by: java.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \ ^ at java.util.regex.Pattern.error(Pattern.java:1924) at java.util.regex.Pattern.compile(Pattern.java:1671) at java.util.regex.Pattern.<init>(Pattern.java:1337) at java.util.regex

Convert empty number as null

馋奶兔 提交于 2019-12-22 18:16:13
问题 is there a possibility to tell my JSF-implementation to convert empty numbers as null. So far I always get 0 (of the corresponging complex-type). For empty strings there is javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL , but I couldn't find anything for numbers. By the way: No, I can't use the vm-argument: -Dorg.apache.el.parser.COERCE_TO_ZERO=false Is a custom-numberconverter my only possibility? 回答1: No, I can't use the vm-argument: -Dorg.apache.el.parser.COERCE_TO_ZERO=false

Thymeleaf: Can I use messages inside expressions

◇◆丶佛笑我妖孽 提交于 2019-12-22 17:59:36
问题 I am using Thymeleaf 3 within a Spring Boot application. Currently I am in a situation where I want to use a message expression inside an EL expression (Spring EL). First use case: trim the message data:title="${#{message.key}.trim()} Second use case: conditionally create an attribute with a message as its value data:title="${condition ? #{message.key} : ''} Both examples will produce a syntax error, because #{ is not an allowed start of an expression. Any ideas how to achieve what I want?