el

What is the difference between expression language functions and custom tags?

只愿长相守 提交于 2019-12-25 03:23:33
问题 Why would I go for custom tags instead of el functions? What are the advantages / disadvantages when they are compared? 回答1: The EL, initially, has been designed to be used inside attributes of the JSTL tags, and any other custom tag you might want to use or write yourself. A later version of the JSP spec has allowed using the EL directly inside the JSPs, but this doesn't mean the JSTL isn't useful anymore. The only thing you can do with EL directly in the JSP is to write some value to the

JSF - ternary operator in value attribute

倖福魔咒の 提交于 2019-12-25 03:11:00
问题 Is it possible to put a ternary operator to have a condition in a "value" attribute of a JSF tag ? And moreover is it possible in a datatable tag to have something like this : <h:dataTable id="table" value="#{myBean.choice ? myBean.listOne : myBean.listTwo}" var="item" > . . . 来源: https://stackoverflow.com/questions/22382466/jsf-ternary-operator-in-value-attribute

<c:forEach> treats items property as a string

陌路散爱 提交于 2019-12-25 02:57:59
问题 I am trying to iterate over a collection of elements, which are complex types (another entities) using <c:forEach> : <c:forEach items="#{repcatTree.items}" var="item"> <div style="padding-top:7px; padding-bottom:7px; padding-right:15px;"> <span class="report_item_category_class"> <h:commandLink rendered="#{item.type == 'category'}" action="#{item.onNodeClicked}" styleClass="default_link"> <h:graphicImage url="/views/tree/images/folder_big.gif" /> <h:outputText value="#{item.attributes.FILE

Why am I not able to find static methods through Expression Language

戏子无情 提交于 2019-12-25 02:41:52
问题 I was having a class MyClass with a static method getmyStaticMethod() While trying to access this method through EL in my jsp : ${MyClass.myStaticMethod} It was giving me unable to find the value for "myStaticMethod" in object of the class MyClass is it because the static method being at Class level and the EL looking only at the Object level is not able to find it ???? Thanks in advance. :) 回答1: The JSP EL can't access static methods of classes. ${MyClass.myStaticMethod} means: find an

Getting java.util.Calendar.YEAR in Spring message code

假如想象 提交于 2019-12-25 01:55:32
问题 <spring:message code="footer.copyriteText" arguments="NEEDS TO BE DYNAMIC" htmlEscape="false"/> I need to replace NEEDS TO BE DYNAMIC with Calendar.getInstance().get(Calendar.YEAR) . How can I achieve this using EL? 回答1: If you don't want hardcode solution like BalusC said you can use this solution Write custom jstl tag like c:set to execute constant path and return constant value then put the constant value to Page scope. This can be done via java Reflection. Use the tag <lib:getConstant

How to output EL as example

随声附和 提交于 2019-12-24 20:48:13
问题 I am creating Facelet components for JSF to be used by other developers in my company. To help those, we have example pages set up, where you could see working examples and the source code to copy, paste and modify in other pages. I need to show an examples of how to use EL in attributes, but I cannot get the EL to be printed out as String without an ugly workaround like attribute="<h:outputText value="#"/> <h:outputText value="{"/> <h:outputText value="myExpression"/> <h:outputText value="}"

How to add custom VariableResolver to JSP Context in Jsp 2.0 to support special EL?

Deadly 提交于 2019-12-24 11:26:56
问题 I'm building my own JSP Tag Library which need to support some features that Application developers can use like this: <w:user-label id="usrlb" value="${session.user}"/> <w:textbox id="tb" label="User Name" value="${usrlb.value.name}"/> which means I want my EL can interact with my Tag declaration. and also I need to add stack concept into this library to support "id namespace" or something. My current research leads me to wrap default JspFactory like this: JspFactory.setDefaultFactory(new

JSP EL parameter list / interface

久未见 提交于 2019-12-24 10:41:39
问题 Is there at a mechanism (preferably compile-time) in JSP to specify required parameters for the JSP accessible by EL , or are the available objects always unknown? There are cases where I want to specify that the JSP expects at least certain named parameters with certain types . 回答1: You can look into Tag Files, where the attribute page directive may suit your needs. This directive allows you to specify the name, type, whether the attribute is required, etc. 来源: https://stackoverflow.com

JSF/IceFaces Conditional Rendering

随声附和 提交于 2019-12-24 09:55:48
问题 I am using Icefaces to conditonally render a component but it cant pick up the boolean: BeanCode: public boolean isEmpty(){ return true; } public int getCount(){ if (isEmpty()){ return 0; } return 1; } IceFaces <ice:panelGroup rendered="#{coverage.empty}"> //this doesnt work <ice:panelGroup rendered="#{coverage.count==0}"> //this does work Error message: Error Parsing: #{coverage.empty} Why is IceFaces not recognising the boolean? 回答1: As you stated, empty is a reserved word in Expression

JSF 2 composite component, passing attributes to backing bean

大兔子大兔子 提交于 2019-12-24 08:33:12
问题 I'm stuck on simple JSF2 question: XHTML: <xvf:simpleOut identifier="12345"/> Composite component is supposed to pass "12345" to backing bean and do some output: <composite:interface> <composite:attribute name="identifier" required="true" type="java.lang.String"/> </composite:interface> <composite:implementation> <!--@elvariable id="arg" type="java.lang.String"--> <ui:param name="arg" value="#{cc.attrs.identifier}"/> <h:outputText value="#{myBean.getTestOutput('???????')}"/> </composite