You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Dean Pullen <de...@msp-uk.com> on 2007/07/05 12:24:48 UTC

Displaytag help in Struts 2

Hi all.

The 'Exposing framework objects to JSTL, with a JSTL and DisplayTag
Example' from here:
http://struts.apache.org/2.0.8/docs/exposing-framework-objects-to-jstl-w
ith-a-jstl-and-displaytag-example.html uses JSTL etc to display a URL
within a displaytag table.
e.g.:

<c:url var="viewurl" value="/viewJobDetail.action">
	<c:param name="name" value="${row.name}"/>
  	<c:param name="groupName" value="${row.group}"/>
</c:url>

Now this does sound displaytag specific, and should be posted on their
related forums/mailing list, but it's actually a more general Struts 2
question, just using displaytag as an example.

Within the displaytag 'display:table' tag, a 'row' object is set into
the page context.
How is this accessible from Struts 2? I've tried all sorts of
combinations to get something like this working:

<s:url action="/MyAction.action" value="${row.param1}">
	<s:param name="messageId" value="${row.param2 }"/>
</s:url>		

But neither param1/param2 ever appear. Am I using the correct OGNL?

Thanks in advance.



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


Re: Displaytag help in Struts 2

Posted by SethVIII <se...@gmail.com>.
Edit:
The issue is with displaytag (really, its documentation), I changed
<display:table id="row" to <display:table uid="row" and I can now see the
current object in page scope, I do not have time today to try it with Struts
tags, but if I can see it anywhere at all, I should be able to get to via
Struts...

--------------------------------------------------
Original:
Like Kishan, I am unable to get the "row" to work...
I never get anything back from #myrow.param, any suggestions?  The rest of
the table using pure displaytag works fine.  I am using displaytag 1.1, my
code is below.

<display:table name="airParameters"
	sort="list"
	pagesize="50"
	requestURI=""
	class="dataDisplay"
	id="row"> 
	<s:set name="myrow"
		value="#attr.row"/> 
	<display:caption media="all"
		class="tableCaption">
		<s:text name="airParameter.table.caption" />
	</display:caption>
	<display:setProperty name="basic.empty.showtable"
					value="true" />
	<display:column property="applicationName"
		title="Application Name"
		sortable="true"
		class="longText" />
	<display:column title="Parameter Value"
		sortable="false"
		class="longText numeric">
		<s:property value="#myrow.applicationName" />
	</display:column>
</display:table>

Thanks for any ideas or suggestions.

-Seth


Jeromy Evans - Blue Sky Minds wrote:
> 
> Yes, I use it as stated previously.  Is row the object you think it is?  
> You either have a typo or you're trying to access properties of row that 
> don't exist.
> 
> The code below shows plain html contained in a column that accesses 
> properties of the current row.
> 
> <s:if test="xxxList.size > 0">
>   <display:table name="xxxList" id="row">
>      <s:set name="myrow" value="#attr.row"/>
>      <display:column sortable="true" title="Name" property="name"/>
>      <display:column sortable="true" title="Date Created" 
> property="dateCreated" decorator="xxx.decorators.ShortDateDecorator"/>
>      <display:column sortable="false" title="Example">
>          View  xxx.action?xxxId=<s:property 
value= "><s:property value="#myrow.name"/> 
>       </display:column>
>    </display:table>
> </s:if>
> 
> * note there are better ways to generate an anchor in a displaytag 
> table.  This is demonstrating how to access the current row using 
> struts2 tags.
> 
> kishanparikh wrote:
>> Hello,
>>
>> Were you able to get the "row" to work? I am trying to get hold of the my
>> properties using the "row" variable inside of a displaytag table. The
>> table
>> itself if working fine.
>>
>> I have tried both the JSTL and the OGNL way but the "row" is always
>> empty.
>>
>> Does anyone know how to get this working for Struts2? Any help is
>> appreciated.
>>
>> Thank you.
>>
>> - Kishan
> 

-- 
View this message in context: http://www.nabble.com/Displaytag-help-in-Struts-2-tf4028889.html#a11709743
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Displaytag help in Struts 2

Posted by SethVIII <se...@gmail.com>.
Like Kishan, I am unable to get the "row" to work...
I never get anything back from #myrow.param, any suggestions?  The rest of
the table using pure displaytag works fine.  I am using displaytag 1.1, my
code is below.

<display:table name="airParameters"
	sort="list"
	pagesize="50"
	requestURI=""
	class="dataDisplay"
	id="row"> 
	<s:set name="myrow"
		value="#attr.row"/> 
	<display:caption media="all"
		class="tableCaption">
		<s:text name="airParameter.table.caption" />
	</display:caption>
	<display:setProperty name="basic.empty.showtable"
					value="true" />
	<display:column property="applicationName"
		title="Application Name"
		sortable="true"
		class="longText" />
	<display:column title="Parameter Value"
		sortable="false"
		class="longText numeric">
		<s:property value="#myrow.applicationName" />
	</display:column>
</display:table>

Thanks for any ideas or suggestions.

-Seth


Jeromy Evans - Blue Sky Minds wrote:
> 
> Yes, I use it as stated previously.  Is row the object you think it is?  
> You either have a typo or you're trying to access properties of row that 
> don't exist.
> 
> The code below shows plain html contained in a column that accesses 
> properties of the current row.
> 
> <s:if test="xxxList.size > 0">
>   <display:table name="xxxList" id="row">
>      <s:set name="myrow" value="#attr.row"/>
>      <display:column sortable="true" title="Name" property="name"/>
>      <display:column sortable="true" title="Date Created" 
> property="dateCreated" decorator="xxx.decorators.ShortDateDecorator"/>
>      <display:column sortable="false" title="Example">
>          View  xxx.action?xxxId=<s:property 
value= "><s:property value="#myrow.name"/> 
>       </display:column>
>    </display:table>
> </s:if>
> 
> * note there are better ways to generate an anchor in a displaytag 
> table.  This is demonstrating how to access the current row using 
> struts2 tags.
> 
> kishanparikh wrote:
>> Hello,
>>
>> Were you able to get the "row" to work? I am trying to get hold of the my
>> properties using the "row" variable inside of a displaytag table. The
>> table
>> itself if working fine.
>>
>> I have tried both the JSTL and the OGNL way but the "row" is always
>> empty.
>>
>> Does anyone know how to get this working for Struts2? Any help is
>> appreciated.
>>
>> Thank you.
>>
>> - Kishan
> 

-- 
View this message in context: http://www.nabble.com/Displaytag-help-in-Struts-2-tf4028889.html#a11709743
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Displaytag help in Struts 2

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Yes, I use it as stated previously.  Is row the object you think it is?  
You either have a typo or you're trying to access properties of row that 
don't exist.

The code below shows plain html contained in a column that accesses 
properties of the current row.

<s:if test="xxxList.size > 0">
  <display:table name="xxxList" id="row">
     <s:set name="myrow" value="#attr.row"/>
     <display:column sortable="true" title="Name" property="name"/>
     <display:column sortable="true" title="Date Created" 
property="dateCreated" decorator="xxx.decorators.ShortDateDecorator"/>
     <display:column sortable="false" title="Example">
         View <a href="xxx.action?xxxId=<s:property 
value="#myrow.id"/>"><s:property value="#myrow.name"/></a>
      </display:column>
   </display:table>
</s:if>

* note there are better ways to generate an anchor in a displaytag 
table.  This is demonstrating how to access the current row using 
struts2 tags.

kishanparikh wrote:
> Hello,
>
> Were you able to get the "row" to work? I am trying to get hold of the my
> properties using the "row" variable inside of a displaytag table. The table
> itself if working fine.
>
> I have tried both the JSTL and the OGNL way but the "row" is always empty.
>
> Does anyone know how to get this working for Struts2? Any help is
> appreciated.
>
> Thank you.
>
> - Kishan
>
> Jeromy Evans - Blue Sky Minds wrote:
>   
>>     
>>> Within the displaytag 'display:table' tag, a 'row' object is set into
>>> the page context.
>>> How is this accessible from Struts 2?
>>>       
>> #attr is the  OGNL to access the page context.    #attr.row will access 
>> your display tag id object named row
>>
>> eg. #1
>>
>> <s:url action="/MyAction.action" value="%{#attr.row.param1}"></s:url>	
>>
>>
>> eg. #2
>>
>> <display:table name="list" id="row">
>>      <s:set name="myrow" value="#attr.row"/>
>>       <s:url action="/MyAction.action" value="%{#myrow.param1}"></s:url>
>>
>> #attr is described here:
>> http://struts.apache.org/2.x/docs/ognl.html
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>>     
>
>   


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


Re: Displaytag help in Struts 2

Posted by kishanparikh <ki...@yahoo.com>.
Hello,

Were you able to get the "row" to work? I am trying to get hold of the my
properties using the "row" variable inside of a displaytag table. The table
itself if working fine.

I have tried both the JSTL and the OGNL way but the "row" is always empty.

Does anyone know how to get this working for Struts2? Any help is
appreciated.

Thank you.

- Kishan

Jeromy Evans - Blue Sky Minds wrote:
> 
> 
>> Within the displaytag 'display:table' tag, a 'row' object is set into
>> the page context.
>> How is this accessible from Struts 2?
> #attr is the  OGNL to access the page context.    #attr.row will access 
> your display tag id object named row
> 
> eg. #1
> 
> <s:url action="/MyAction.action" value="%{#attr.row.param1}"></s:url>	
> 
> 
> eg. #2
> 
> <display:table name="list" id="row">
>      <s:set name="myrow" value="#attr.row"/>
>       <s:url action="/MyAction.action" value="%{#myrow.param1}"></s:url>
> 
> #attr is described here:
> http://struts.apache.org/2.x/docs/ognl.html
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Displaytag-help-in-Struts-2-tf4028889.html#a11650054
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Displaytag help in Struts 2

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
> Within the displaytag 'display:table' tag, a 'row' object is set into
> the page context.
> How is this accessible from Struts 2?
#attr is the  OGNL to access the page context.    #attr.row will access 
your display tag id object named row

eg. #1

<s:url action="/MyAction.action" value="%{#attr.row.param1}"></s:url>	


eg. #2

<display:table name="list" id="row">
     <s:set name="myrow" value="#attr.row"/>
      <s:url action="/MyAction.action" value="%{#myrow.param1}"></s:url>

#attr is described here:
http://struts.apache.org/2.x/docs/ognl.html

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