ognl

Comparing struts ognl value to scriptlet value in JSP

I have to compare this to a value like below: ${page_id } ---- <% out.print(a); %> <c:if test="${page_id != a}"> How can I do this? ...

.NET port of OGNL Library

Does anyone know of a good .NET port of the OGNL library here? It looks like I could use something like this and the only one I have found so far is on SourceForge here and hasn't been updated since 2005. ...

OGNL Hello World in Java

I need to use OGNL for reading some properties from Java object. OGNL is completely new thing to me. The documentation available for OGNL is OGNL's website is really confusing to me. So anyone can provide a simple HelloWorld example for using OGNL (or any link to a tutorial is also helpful). ...

How to fix redirect OGNL error, Unable to set param?

I am not sure if this is me or if this is a bug. I got the following error 11:52:01,623 ERROR ObjectFactory:27 - Unable to set parameter [dest] in result of type [org.apache.struts2.dispatcher.ServletRedirectResult] Caught OgnlException while setting property 'dest' on type 'org.apache.struts2.dispatcher.ServletRedirectResult'. - Class...

Struts ognl expression to evalulate the result of the expression

This is going to be a little tricky to explain. I'm trying to write a tag to componentise a bunch of address fields, but I'm having trouble working out the ognl expression. Expected usage: member.address maps to an Address object (nothing too cleaver). my tag (simplest version): <%@taglib prefix="s" uri="/struts-tags" %> <%@attr...

How to get request locale in OGNL?

Hi, I want to know how to get request locale in OGNL? For now I use <s:set var="locale" value='#session.WW_TRANS_I18N_LOCALE?#session.WW_TRANS_I18N_LOCALE.toString():"zh_CN"'/> This must assume that the initial value is "zh_CN". So I need to know how to get request locale in OGNL. Thx ...

Difference between '#','%' and '$'

I'm new to struts2 and confused by the '#','%' and '$' element. There are some usages like: ${user.name} %{user.name} <s:radio list="#{key1:value1,key2:value2}" /> Could any give me an explanation and examples? ...

How can I get the revision number into an Ant property in Luntbuild?

I'm sure this must be possible: I want to have the revision number (from Subversion) put into a property that is accessible from Ant when my build runs in Luntbuild. There must be an OGNL expression that I can add to the Build Properties box on the configuration page for my Ant builder. Does anyone know what it is? ...

How do I set a float without using an OGNL converter?

I have a class that looks like this: public class Foobar { private float value; public void setValue(float value) { this.value = value; } } I then have a webpage (Struts2) that passed in a variable foobar.value. <input type="text" name="foobar.value" value="123.456"> I then get this error: ognl.MethodFailedException...

struts 2, tiles 2 dynamic title

Hi Gurus, I am using tiles 2.0.6 as my template framework together with struts 2.1.6. I am writing a simple cms page and want to let the user to define the title of each html page. I have a title definition like this <definition name="base" template="/WEB-INF/jsp/templates/base.jsp"> <put-attribute name="title" value=" "/>...

Format number in Struts 2 <s:property/> tag

I would like to format number displayed by <s:property value="summary.total"/> tag in Struts 2. There is a double value. How can I do that? Should I use OGNL? Or maybe I must use <s:text/> tag and define my format in resuource file? ...

Multiple field ognl type converter

I have a form with (at the moment) two fields and submit the following: capture.id = 213 capture.description = DescriptionText The target object 'capture' is immutable and I would like to provide a type converter to take both values and call the constructor. What I cannot seem to do is get by TypeConverter to be invoked. If the input...

Struts2 taglib, compare with null

I am trying to know why this code is not working when I compare a String with null in a JSP. <s:set name="myvar" value="%{'teststring' != null}" /> <!-- always true --> myvar value is ${myvar} Above code works fine, and prints "myvar value is true". But doing any of these <s:property value="myvar" /> <s:property value="%{myvar}" /> ...

Advantages of OGNL usage over typical EL in Struts2

Say that I don't leverage OGNL to create my Struts2 web application and just purely uses typical el provided by Sun. What would be the downside of it? As far as I know, OGNL is a kind of expression which attempts to match the best matched value from ValueStack based on its current state. Could it also be achieved by just using EL alon...

Using OGNL to return data from a Map<String,Object>

Using Struts 2.1.6, xwork 2.1.2 and ognl 2.6.11 In my struts action I have a Map that I am fetching elements from using OGNL. If the key I am using to fetch with does not exist in the map then OGNL returns an empty object array, that OGNL converts to a string and I get the object reference java.lang.Object@6.... This occurs in several p...

Struts2 ognlproblem

Hi All, i've got a strange problem with struts2 : if in a jsp i would like to access to a session variable it's quite simple i just call (for example) <s:property value="%{#session['LoggedUser'].name}"/> if the String 'LoggedUser' is in a variable i can access to them with <s:property value="%{#session[@pkg.ClassName@Var].name}"/> q...

Object tree navigation language in Java

In the system which I'm currently developing I often have to navigate an object tree and based on its state and values take actions. In normal Java this results in tedious for loops, if statements etc... Are there alternative ways to achieve tree navigation, similar to XPath for XML? I know there is JXPath and OGNL, but do you know any o...

Compare Long values Struts2

Hi everyone I'm trying to compare two values using struts2 s:if tag but its not working. If I hardcode the values it works but I want it to be dynamic. The variable stringValue is of type String. The variable currentLongValue is of type Long. <s:set var="stringValue" value="order"/> <s:iterator value="listTest"> <s:set var="currentLon...

OGNL thread safety

I'm going to reuse OGNL library out of Struts2 scope. I have rather large set of formulas, that is why I would like to precompile all of them: Ognl.parseExpression(expressionString); But I'm not sure if precompiled expression can be used in multi-thread environment. Does anybody knows if it can be used? ...

Struts2 scriptlet

Using struts2 with jsp with standard struts tag libraries. I'm trying to dynamically hide a DIV on page load, but still send it to the browser. This is so I can show it later via javascript. The request objects one and two are not easily referenced via a jsp:usebean tag. (They are enums and cannot be instantiated) I tried using a ...