You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by phillip rhodes <rh...@yahoo.com> on 2004/08/04 18:23:08 UTC

ognl help, how do I pass ognl reference to another ognl expression?

I am using the Foreach component, where my value is
set to the ognl expression "ognl:filterItem"

I need to pass the current filterItem in the loop as a
parameter to a method in a second ognl expression.

ognl:requestCycle.requestContext.session.attribute(filterItem.filter.key)

I have tried a lot of combinations, and a lot of
googling but to no avail.
Any guidance would be appreciated.

Phillip

<tr jwcid="@Foreach" 
	source="ognl:currentQuery.filterItems" 
	value="ognl:filterItem" element="tr">
	<select jwcid="@Select">
		<span jwcid="@Foreach" 
		
source="ognl:requestCycle.requestContext.session.attribute(filterItem.filter.key)"

			value="ognl:dataFilterItem">
			<option jwcid="@Option" 
				selected="ognl:dataFilterItem.selected" 
				label="ognl:dataFilterItem.label"/>
		</span>
	</select>
</tr>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: ognl help, how do I pass ognl reference to another ognl expression?

Posted by Jamie Orchard-Hays <ja...@dang.com>.
Give your first Foreach a name:
foo@Foreach

In the second loop, reference it:
components.foo.value.filter.key

Though I would think your version would work.

----- Original Message ----- 
From: "phillip rhodes" <rh...@yahoo.com>
To: <ta...@jakarta.apache.org>
Sent: Wednesday, August 04, 2004 12:23 PM
Subject: ognl help, how do I pass ognl reference to another ognl expression?


> I am using the Foreach component, where my value is
> set to the ognl expression "ognl:filterItem"
>
> I need to pass the current filterItem in the loop as a
> parameter to a method in a second ognl expression.
>
> ognl:requestCycle.requestContext.session.attribute(filterItem.filter.key)
>
> I have tried a lot of combinations, and a lot of
> googling but to no avail.
> Any guidance would be appreciated.
>
> Phillip
>
> <tr jwcid="@Foreach"
> source="ognl:currentQuery.filterItems"
> value="ognl:filterItem" element="tr">
> <select jwcid="@Select">
> <span jwcid="@Foreach"
>
>
source="ognl:requestCycle.requestContext.session.attribute(filterItem.filter
.key)"
>
> value="ognl:dataFilterItem">
> <option jwcid="@Option"
> selected="ognl:dataFilterItem.selected"
> label="ognl:dataFilterItem.label"/>
> </span>
> </select>
> </tr>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: ognl help, how do I pass ognl reference to another ognl expression?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
use session.getAttribute(filterItem.filter.key) .... if you are calling 
a method that takes parameters, you need to spell it out (even with the 
'get' prefix).  I'm sure there is some slicker OGNL syntax (maybe 
session.attribute[filterItem.filter.key]?) that would work, but 
getAttribute should do the trick.

	Erik


On Aug 4, 2004, at 3:42 PM, phillip rhodes wrote:

> Good point...  I was assuming that I had a badly
> formed ognl expression.
>
> It appears that it ognl is not able to find the
> getAttribute method on the HttpSession object.
>
> any insights?
>
>
> org.apache.tapestry.BindingException
> Unable to resolve expression
> 'requestCycle.requestContext.session.attribute(filterItem.filter.key)'
> for
> com.rhoderunner.adhocquery.pages.Home$Enhance_0@1cf662f[Home].
> binding: 	ExpressionBinding[Home
> requestCycle.requestContext.session.attribute(filterItem.filter.key)]
> location: 	context:/Home.html, line 253
>
> ognl.MethodFailedException
> Method "attribute" failed for object
> org.apache.catalina.session.StandardSessionFacade@1d8f162
>
> java.lang.NoSuchMethodException
> attribute(java.lang.String)
> Stack Trace:
>
>     *
> ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:783)
>     *
> ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:61)
>     *
> ognl.OgnlRuntime.callMethod(OgnlRuntime.java:819)
>     * ognl.ASTMethod.getValueBody(ASTMethod.java:75)
>     *
> ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:171)
>     * ognl.SimpleNode.getValue(SimpleNode.java:213)
>
>
>
> --- Erik Hatcher <er...@ehatchersolutions.com> wrote:
>
>> And the error message you get is....???
>>
>>
>> On Aug 4, 2004, at 12:23 PM, phillip rhodes wrote:
>>
>>> I am using the Foreach component, where my value
>> is
>>> set to the ognl expression "ognl:filterItem"
>>>
>>> I need to pass the current filterItem in the loop
>> as a
>>> parameter to a method in a second ognl expression.
>>>
>>> ognl:
>>>
>>
> requestCycle.requestContext.session.attribute(filterItem.filter.key)
>>>
>>> I have tried a lot of combinations, and a lot of
>>> googling but to no avail.
>>> Any guidance would be appreciated.
>>>
>>> Phillip
>>>
>>> <tr jwcid="@Foreach"
>>> 	source="ognl:currentQuery.filterItems"
>>> 	value="ognl:filterItem" element="tr">
>>> 	<select jwcid="@Select">
>>> 		<span jwcid="@Foreach"
>>> 		
>>> source="ognl:
>>>
>>
> requestCycle.requestContext.session.attribute(filterItem.filter.key)"
>>>
>>> 			value="ognl:dataFilterItem">
>>> 			<option jwcid="@Option"
>>> 				selected="ognl:dataFilterItem.selected"
>>> 				label="ognl:dataFilterItem.label"/>
>>> 		</span>
>>> 	</select>
>>> </tr>
>>>
>>>
>>
> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail:
>> tapestry-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail:
>> tapestry-user-help@jakarta.apache.org
>>
>>
>>
> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
>> tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail:
>> tapestry-user-help@jakarta.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: ognl help, how do I pass ognl reference to another ognl expression?

Posted by Jamie Orchard-Hays <ja...@dang.com>.
Yeah, ognl won't doesn't use a shorthand for parameterized methods. Gotta
use getFoo(bar).


----- Original Message ----- 
From: "Danny Mandel" <dm...@tolweb.org>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Wednesday, August 04, 2004 3:56 PM
Subject: Re: ognl help, how do I pass ognl reference to another ognl
expression?


> I'm not sure about the OGNL internals as to why this is the case, but
> I've found that when calling a method with parameters, you must give the
> full method name to make it work.  I tested it in your case and it fixed
> the problem (I'm running with Jetty instead of Tomcat, but that
> shouldn't make a difference I don't think)
>
> This broke for me also:
>
> requestCycle.requestContext.session.attribute('some name of an attribute')
>
> But this works:
>
> requestCycle.requestContext.session.getAttribute('some name of an
attribute')
>
>
> Hope that helps,
> Danny
>
> phillip rhodes wrote:
>
> >Good point...  I was assuming that I had a badly
> >formed ognl expression.
> >
> >It appears that it ognl is not able to find the
> >getAttribute method on the HttpSession object.
> >
> >any insights?
> >
> >
> >org.apache.tapestry.BindingException
> >Unable to resolve expression
> >'requestCycle.requestContext.session.attribute(filterItem.filter.key)'
> >for
> >com.rhoderunner.adhocquery.pages.Home$Enhance_0@1cf662f[Home].
> >binding: ExpressionBinding[Home
> >requestCycle.requestContext.session.attribute(filterItem.filter.key)]
> >location: context:/Home.html, line 253
> >
> >ognl.MethodFailedException
> >Method "attribute" failed for object
> >org.apache.catalina.session.StandardSessionFacade@1d8f162
> >
> >java.lang.NoSuchMethodException
> >attribute(java.lang.String)
> >Stack Trace:
> >
> >    *
> >ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:783)
> >    *
> >ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:61)
> >    *
> >ognl.OgnlRuntime.callMethod(OgnlRuntime.java:819)
> >    * ognl.ASTMethod.getValueBody(ASTMethod.java:75)
> >    *
> >ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:171)
> >    * ognl.SimpleNode.getValue(SimpleNode.java:213)
> >
> >
> >
> >--- Erik Hatcher <er...@ehatchersolutions.com> wrote:
> >
> >
> >
> >>And the error message you get is....???
> >>
> >>
> >>On Aug 4, 2004, at 12:23 PM, phillip rhodes wrote:
> >>
> >>
> >>
> >>>I am using the Foreach component, where my value
> >>>
> >>>
> >>is
> >>
> >>
> >>>set to the ognl expression "ognl:filterItem"
> >>>
> >>>I need to pass the current filterItem in the loop
> >>>
> >>>
> >>as a
> >>
> >>
> >>>parameter to a method in a second ognl expression.
> >>>
> >>>ognl:
> >>>
> >>>
> >>>
> >requestCycle.requestContext.session.attribute(filterItem.filter.key)
> >
> >
> >>>I have tried a lot of combinations, and a lot of
> >>>googling but to no avail.
> >>>Any guidance would be appreciated.
> >>>
> >>>Phillip
> >>>
> >>><tr jwcid="@Foreach"
> >>> source="ognl:currentQuery.filterItems"
> >>> value="ognl:filterItem" element="tr">
> >>> <select jwcid="@Select">
> >>> <span jwcid="@Foreach"
> >>>
> >>>source="ognl:
> >>>
> >>>
> >>>
> >requestCycle.requestContext.session.attribute(filterItem.filter.key)"
> >
> >
> >>> value="ognl:dataFilterItem">
> >>> <option jwcid="@Option"
> >>> selected="ognl:dataFilterItem.selected"
> >>> label="ognl:dataFilterItem.label"/>
> >>> </span>
> >>> </select>
> >>></tr>
> >>>
> >>>
> >>>
> >>>
> >---------------------------------------------------------------------
> >
> >
> >>>To unsubscribe, e-mail:
> >>>
> >>>
> >>tapestry-user-unsubscribe@jakarta.apache.org
> >>
> >>
> >>>For additional commands, e-mail:
> >>>
> >>>
> >>tapestry-user-help@jakarta.apache.org
> >>
> >>
> >>
> >>
> >>
> >---------------------------------------------------------------------
> >
> >
> >>To unsubscribe, e-mail:
> >>tapestry-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail:
> >>tapestry-user-help@jakarta.apache.org
> >>
> >>
> >>
> >>
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: ognl help, how do I pass ognl reference to another ognl expression?

Posted by Danny Mandel <dm...@tolweb.org>.
I'm not sure about the OGNL internals as to why this is the case, but 
I've found that when calling a method with parameters, you must give the 
full method name to make it work.  I tested it in your case and it fixed 
the problem (I'm running with Jetty instead of Tomcat, but that 
shouldn't make a difference I don't think)

This broke for me also:

requestCycle.requestContext.session.attribute('some name of an attribute')

But this works:

requestCycle.requestContext.session.getAttribute('some name of an attribute')


Hope that helps,
Danny

phillip rhodes wrote:

>Good point...  I was assuming that I had a badly
>formed ognl expression.
>
>It appears that it ognl is not able to find the
>getAttribute method on the HttpSession object.  
>
>any insights?
>
>
>org.apache.tapestry.BindingException
>Unable to resolve expression
>'requestCycle.requestContext.session.attribute(filterItem.filter.key)'
>for
>com.rhoderunner.adhocquery.pages.Home$Enhance_0@1cf662f[Home].
>binding: 	ExpressionBinding[Home
>requestCycle.requestContext.session.attribute(filterItem.filter.key)]
>location: 	context:/Home.html, line 253
> 
>ognl.MethodFailedException
>Method "attribute" failed for object
>org.apache.catalina.session.StandardSessionFacade@1d8f162
> 
>java.lang.NoSuchMethodException
>attribute(java.lang.String)
>Stack Trace:
>
>    *
>ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:783)
>    *
>ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:61)
>    *
>ognl.OgnlRuntime.callMethod(OgnlRuntime.java:819)
>    * ognl.ASTMethod.getValueBody(ASTMethod.java:75)
>    *
>ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:171)
>    * ognl.SimpleNode.getValue(SimpleNode.java:213)
>
>
>
>--- Erik Hatcher <er...@ehatchersolutions.com> wrote:
>
>  
>
>>And the error message you get is....???
>>
>>
>>On Aug 4, 2004, at 12:23 PM, phillip rhodes wrote:
>>
>>    
>>
>>>I am using the Foreach component, where my value
>>>      
>>>
>>is
>>    
>>
>>>set to the ognl expression "ognl:filterItem"
>>>
>>>I need to pass the current filterItem in the loop
>>>      
>>>
>>as a
>>    
>>
>>>parameter to a method in a second ognl expression.
>>>
>>>ognl: 
>>>
>>>      
>>>
>requestCycle.requestContext.session.attribute(filterItem.filter.key)
>  
>
>>>I have tried a lot of combinations, and a lot of
>>>googling but to no avail.
>>>Any guidance would be appreciated.
>>>
>>>Phillip
>>>
>>><tr jwcid="@Foreach"
>>>	source="ognl:currentQuery.filterItems"
>>>	value="ognl:filterItem" element="tr">
>>>	<select jwcid="@Select">
>>>		<span jwcid="@Foreach"
>>>		
>>>source="ognl: 
>>>
>>>      
>>>
>requestCycle.requestContext.session.attribute(filterItem.filter.key)"
>  
>
>>>			value="ognl:dataFilterItem">
>>>			<option jwcid="@Option"
>>>				selected="ognl:dataFilterItem.selected"
>>>				label="ognl:dataFilterItem.label"/>
>>>		</span>
>>>	</select>
>>></tr>
>>>
>>>
>>>      
>>>
>---------------------------------------------------------------------
>  
>
>>>To unsubscribe, e-mail:
>>>      
>>>
>>tapestry-user-unsubscribe@jakarta.apache.org
>>    
>>
>>>For additional commands, e-mail:
>>>      
>>>
>>tapestry-user-help@jakarta.apache.org
>>
>>
>>
>>    
>>
>---------------------------------------------------------------------
>  
>
>>To unsubscribe, e-mail:
>>tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail:
>>tapestry-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: ognl help, how do I pass ognl reference to another ognl expression?

Posted by phillip rhodes <rh...@yahoo.com>.
Good point...  I was assuming that I had a badly
formed ognl expression.

It appears that it ognl is not able to find the
getAttribute method on the HttpSession object.  

any insights?


org.apache.tapestry.BindingException
Unable to resolve expression
'requestCycle.requestContext.session.attribute(filterItem.filter.key)'
for
com.rhoderunner.adhocquery.pages.Home$Enhance_0@1cf662f[Home].
binding: 	ExpressionBinding[Home
requestCycle.requestContext.session.attribute(filterItem.filter.key)]
location: 	context:/Home.html, line 253
 
ognl.MethodFailedException
Method "attribute" failed for object
org.apache.catalina.session.StandardSessionFacade@1d8f162
 
java.lang.NoSuchMethodException
attribute(java.lang.String)
Stack Trace:

    *
ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:783)
    *
ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:61)
    *
ognl.OgnlRuntime.callMethod(OgnlRuntime.java:819)
    * ognl.ASTMethod.getValueBody(ASTMethod.java:75)
    *
ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:171)
    * ognl.SimpleNode.getValue(SimpleNode.java:213)



--- Erik Hatcher <er...@ehatchersolutions.com> wrote:

> And the error message you get is....???
> 
> 
> On Aug 4, 2004, at 12:23 PM, phillip rhodes wrote:
> 
> > I am using the Foreach component, where my value
> is
> > set to the ognl expression "ognl:filterItem"
> >
> > I need to pass the current filterItem in the loop
> as a
> > parameter to a method in a second ognl expression.
> >
> > ognl: 
> >
>
requestCycle.requestContext.session.attribute(filterItem.filter.key)
> >
> > I have tried a lot of combinations, and a lot of
> > googling but to no avail.
> > Any guidance would be appreciated.
> >
> > Phillip
> >
> > <tr jwcid="@Foreach"
> > 	source="ognl:currentQuery.filterItems"
> > 	value="ognl:filterItem" element="tr">
> > 	<select jwcid="@Select">
> > 		<span jwcid="@Foreach"
> > 		
> > source="ognl: 
> >
>
requestCycle.requestContext.session.attribute(filterItem.filter.key)"
> >
> > 			value="ognl:dataFilterItem">
> > 			<option jwcid="@Option"
> > 				selected="ognl:dataFilterItem.selected"
> > 				label="ognl:dataFilterItem.label"/>
> > 		</span>
> > 	</select>
> > </tr>
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: ognl help, how do I pass ognl reference to another ognl expression?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
And the error message you get is....???


On Aug 4, 2004, at 12:23 PM, phillip rhodes wrote:

> I am using the Foreach component, where my value is
> set to the ognl expression "ognl:filterItem"
>
> I need to pass the current filterItem in the loop as a
> parameter to a method in a second ognl expression.
>
> ognl: 
> requestCycle.requestContext.session.attribute(filterItem.filter.key)
>
> I have tried a lot of combinations, and a lot of
> googling but to no avail.
> Any guidance would be appreciated.
>
> Phillip
>
> <tr jwcid="@Foreach"
> 	source="ognl:currentQuery.filterItems"
> 	value="ognl:filterItem" element="tr">
> 	<select jwcid="@Select">
> 		<span jwcid="@Foreach"
> 		
> source="ognl: 
> requestCycle.requestContext.session.attribute(filterItem.filter.key)"
>
> 			value="ognl:dataFilterItem">
> 			<option jwcid="@Option"
> 				selected="ognl:dataFilterItem.selected"
> 				label="ognl:dataFilterItem.label"/>
> 		</span>
> 	</select>
> </tr>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org