el

Problem with session attributes in JSP EL using Spring MVC

做~自己de王妃 提交于 2019-12-18 04:11:36
问题 I'm trying to show a session attribute "userSession" in a jsp page using JSP EL, but it returns null (case 1). Request attributes are shown properly in EL expressions though. Using java scriptlet instead, behaves as shown in cases 2 and 3: <c:out value="${userSession}"/> \\Returns null <c:out value='<%=request.getSession().getAttribute("userSession")%>'/> \\Works fine - returns session attribute <c:out value='<%=session.getAttribute("userSession")%>'/> \\Throws exception: cannot find variable

nesting of el expressions in JSF for resource API

喜夏-厌秋 提交于 2019-12-18 03:58:05
问题 <p:graphicImage value="#{resource['images:primefaces-ui/#{car.manufacturer}.jpg']}"/> I would like to calculate the inner el first and then calculate the path using resource API. I tried <c:set> tag but its variable is also an EL, so it does not make any difference. 回答1: In the current EL 2.2 version, you cannot nest EL expressions nor String-concatenate EL variables that way. Use <c:set> to prepare the dynamic key before using it in another EL expression by simply inlining the EL expression

nesting JSF expression strings

筅森魡賤 提交于 2019-12-17 21:06:11
问题 I want to achieve this using dynamic parameters for value expressions: <h:dataTable value="#{someBean.someValue}" var="field"> <h:column>#{anotherBean[field]}</h:column> </h:dataTable> where field is 'user.name' or 'location.address.zip' or... Is it possible? Note that this is a simple example, I'm interested in ValueExpression not in dataTable component. UPDATE now the question is: how to replace standard BeanELResolver? looking in ELUtils: ... composite.addRootELResolver(IMPLICIT_RESOLVER);

EL expression inside p:commandButton onclick does not update/re-render on ajax request?

谁说我不能喝 提交于 2019-12-17 20:55:08
问题 The onclick attribute of my commandButton has some EL dependent Javascript inside. To be more specific, here is that piece of code: <p:commandButton onclick="javascript: if('#{userBean.user.friendList.size() gt 0}' == 'true') deleteFriendsConfirmDialog.show(); else friendsAlreadyDeletedErrorDialog.show();" value="Delete all friends?" /> deleteFriendsConfirmDialog clears the list of friends and updates the @form . The list of friends, commandButton and the dialogs are all in that form. So I

Using f:selectItems var in passtrough attribute

依然范特西╮ 提交于 2019-12-17 20:47:23
问题 can I pass expressions to JSF 2 passthrough-attributes? the following code is not working. expression #{country.isoCode} is not evaluated. <h:selectOneMenu value="#{bean.selectedCountry}" styleClass="selectlist"> <f:selectItems value="#{bean.countries}" var="country" itemLabel="#{country.countryName}" pt:data-icon="flag flag-#{country.isoCode}"/> </h:selectOneMenu> I am using namespace xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" and bootstrap-select. attribute "data-icon" is used to show

Comparing numbers in EL expression does not seem to work

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 20:25:18
问题 In JSP, I want to compare two variables If I do: <c:set var="pagerTotDisp" value="9"/> <c:if test="${pagerTotDisp > 8}"> <span>pagerTotDisp above 8</span> </c:if> It displays "pagerTotDisp above 8" as expected <c:set var="TotalPages" value="10"/> <c:if test="${TotalPages > 2}"> <span>TotalPages above 2</span> </c:if> It displays "pagerTotDisp above 8" as expected But then if I do <c:set var="pagerTotDisp" value="9"/> <c:set var="TotalPages" value="10"/> <c:if test="${TotalPages < pagerTotDisp

Call methods in Expression Language

北慕城南 提交于 2019-12-17 20:22:16
问题 How can I invoke a method in JSP using EL (Expression Language)? For example: <c:forEach var="item" items="${listStr}" begin="0" end="2" step="2"> <p>${item.indexOf("h")}</p> </c:forEach> Here, the item is an object of type java.lang.String . This causes errors when run on Tomcat. 回答1: This is only supported since EL 2.2. This goes in turn hand in hand with Servlet 3.0. So if you make sure that you target a Servlet 3.0 compatible container (Tomcat 7, Glassfish 3, etc) with a Servlet 3.0

Using conditional operator in h:inputText value and h:commandButton actionListener

99封情书 提交于 2019-12-17 20:11:16
问题 I want to load two difference panel in .xhtml file. <h:inputText value="#{param['from']=='TERMINAL' ? terminalsList.globalFilter : merchantsList.globalFilter}" size="50" /> <h:commandButton value="Filter" actionListener="#{param['from']=='TERMINAL' ? terminalsList.filterTerminals : merchantsList.filterMerchants}" /> <h:commandButton value="Reset" actionListener="#{param['from']=='TERMINAL' ? terminalsList.resetTerminalsFilter : merchantsList.resetMerchantsFilter}" /> when http get request

Collection/Array contains method

核能气质少年 提交于 2019-12-17 19:51:12
问题 i was wondering if there's contains method for collections/array in EL 2.2 or i will have to make a custom one ? REQUIREMENT : i have a string array, and i want to find if it contains a specific string. CASE : i am looping on list of input checkboxes to render them, and i want to check the current checkbox, if it's value exists in the array of checkboxes. UPDATE : is such method is available in EL? If such method is not available, then please provide your suggestion for best performance

The representation of if-elseif-else in EL using JSF

混江龙づ霸主 提交于 2019-12-17 18:45:19
问题 The following JSF code contains two separate <c:if></c:if> . Let's look at it. <?xml version='1.0' encoding='UTF-8' ?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:c="http://java.sun.com/jsp/jstl/core"> <h:head> <title>JSF EL</title> </h:head> <h:body> <h:form> <c:set scope="request" var="row" property="x" value="10"/> <c:if test="#{row==10}"> <h:outputLabel value="value = 10"/> </c:if> <c:if test="#{row==15}"> <h:outputLabel value="value = 15"/> </c