You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by holod <se...@gmail.com> on 2008/07/25 10:35:46 UTC

Nothing helps

attribute "var" doesn't exist in my struts-tags.tld. I'm using the last one
struts2 pack.

lawDraft.docs returns List with 5 elements.
Simple printing </s:property value="lawDraft.docs"> shows 5 elements

I've tried to invoke method "getTitle()" of class Document which instances
are in ArrayList:
1.
<s:iterator value="lawDraft.docs" status="document" id="doc">
</s:property value ="title">
</s:iterator>
Nothing, empty string

2.
<s:iterator value="lawDraft.docs" status="document" id="doc">
</s:property value ="%{#doc.title}">
</s:iterator>
Nothing, empty string

Previous actions prints to log fields of objects kept in Lawdraft.getDocs()
I know, that title is not null or empty.

Can you suggest me something else?
-- 
View this message in context: http://www.nabble.com/Problem-accessing-iterated-object-%28%3Cs%3Aiterator%29-tp18614028p18647504.html
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: Nothing helps

Posted by Lukasz Lenart <lu...@googlemail.com>.
2008/7/25 holod <se...@gmail.com>:
>
> attribute "var" doesn't exist in my struts-tags.tld. I'm using the last one
> struts2 pack.

"var" attribute is used as from S2.1 and above which was not released
yet (2.1.2 is beta), the latest release is 2.0.11.2, which version do
you have?

> <s:iterator value="lawDraft.docs" status="document" id="doc">
> </s:property value ="title">
> </s:iterator>

try </s:property value ="doc.title">


Regards
-- 
Lukasz
http://www.lenart.org.pl/

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


Re: Iterator index: how to index html elements?

Posted by Joachim Ansorg <ja...@ksi.gr>.
Hi,
> I use this code:
> <s:iterator value="lawDraft.docs" id="doc" status="document">
>      <s:param name="rawMainDocIdParam" value="attachedMainDocRow<s:property
> value="document.index"/>"/>
>      <tr id="%{#rawMainDocIdParam}">
>           some content
>      </tr>
> </s:iterator>
>   

For this I usually do something like (untested):

<s:iterator ...>
    <s:set var="i" value="%{#status.index}"/>
    <tr id="row_${i}">...</tr>
</s:iterator>

Btw, you can't use OGNL expression in non-struts tags (you tried to use 
it in tr).
There's a tabletags taglib for struts2, which might be useful for you.

Hope that helps,
Joachim
> The problem is: I'm trying to access status (starts from 0) of iterator,
> I've tried
> <s:param name="rawMainDocIdParam" value="attachedMainDocRow<s:property
> value="document.index"/>"/>
> I get error: "No information about attribute tag document.index"
> I've tried 
> <s:param name="rawMainDocIdParam" value="attachedMainDocRow<s:property
> value="#document.index"/>"/>
> and
> <s:param name="rawMainDocIdParam" value="attachedMainDocRow<s:property
> value="%{#document.index}"/>"/>
> In both cases I get error "Can't convert to xml document.index"
>
> Any suggestions, please, can't understand mistake.
>   


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


Re: Iterator index: how to index html elements?

Posted by Dave Newton <ne...@yahoo.com>.
--- On Mon, 7/28/08, holod <se...@gmail.com> wrote:
> <tr id="attachedMainDocRow<s:property value="#document.status"/>">
> Some content
> </tr>
> 
> Is there any issues with status of iterator?

None that I'm aware of; I use it all the time.

I'd strongly recommend not naming your status variable "document", since it's not a document. It's a status.

It wouldn't be #document.status, it would be #document.index; see [1].

Dave

[1] http://struts.apache.org/2.0.11.2/struts2-core/apidocs/org/apache/struts2/views/jsp/IteratorStatus.html

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


Re: Iterator index: how to index html elements? count works, but status doesn't

Posted by Jim Kiley <jh...@summa-tech.com>.
The version of IteratorStatus found in version 2.0.11 of the docs [1] has a
getIndex() method; has it subsequently been vaporized?

[1]
http://struts.apache.org/2.0.11/struts2-core/apidocs/index.html?org/apache/struts2/views/jsp/IteratorStatus.html

jk

On Mon, Jul 28, 2008 at 4:28 AM, holod <se...@gmail.com> wrote:

>
> <tr id="attachedMainDocRow<s:property value="#document.count"/>">
>
> works fine. It just starts from 1, not from 0
> Why? I can't understand what has happened to index.
> count is not so bad, thanks for you help and cooperation!
> --
> View this message in context:
> http://www.nabble.com/Problem-accessing-iterated-object-%28%3Cs%3Aiterator%29-tp18614028p18686074.html
> 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
>
>


-- 
Jim Kiley
Technical Consultant | Summa
[p] 412.258.3346 [m] 412.445.1729
http://www.summa-tech.com

Re: Iterator index: how to index html elements? count works, but status doesn't

Posted by holod <se...@gmail.com>.
<tr id="attachedMainDocRow<s:property value="#document.count"/>">

works fine. It just starts from 1, not from 0
Why? I can't understand what has happened to index.
count is not so bad, thanks for you help and cooperation!
-- 
View this message in context: http://www.nabble.com/Problem-accessing-iterated-object-%28%3Cs%3Aiterator%29-tp18614028p18686074.html
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: Iterator index: how to index html elements?

Posted by holod <se...@gmail.com>.

That's not valid JSP; you can't nest tags like that.

> Any suggestions, please, can't understand mistake.

That's not what <s:param...> is for; it's for parameterizing other tags.

<tr id="foo<s:property value="#status.index">">bar</tr>

You could use <s:set...> to create the ID if you don't want to create it
on-the-fly.

<tr id="attachedMainDocRow<s:property value="#document.status"/>">
Some content
</tr>

When I inspect source of generated html page, I see:
<tr id="attachedMainDocRow">
Some content
</tr>

My rows were printed several times (that's ok), but #document.status is not
used, seems like  it's "" or null, but it can't be so. My iterator iterates
several times and gets values from list.

Is there any issues with status of iterator?

---------------------------------------------------------------------
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/Problem-accessing-iterated-object-%28%3Cs%3Aiterator%29-tp18614028p18685977.html
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: Iterator index: how to index html elements?

Posted by Dave Newton <ne...@yahoo.com>.
--- On Mon, 7/28/08, holod <se...@gmail.com> wrote:
> [...] but I want to set id attribute for them:
> <tr id="MyGeneratedRow0">some content</tr>
> [...]
> 
> I use this code:
> <s:iterator value="lawDraft.docs" id="doc" status="document">
>      <s:param name="rawMainDocIdParam"
> value="attachedMainDocRow<s:property
> value="document.index"/>"/>

That's not valid JSP; you can't nest tags like that.

> Any suggestions, please, can't understand mistake.

That's not what <s:param...> is for; it's for parameterizing other tags.

<tr id="foo<s:property value="#status.index">">bar</tr>

You could use <s:set...> to create the ID if you don't want to create it on-the-fly.

Dave


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


Iterator index: how to index html elements?

Posted by holod <se...@gmail.com>.
Now, I have another problem:
My iterator generates <tr>some content</tr>
I want to give id="bla-bla" to my generated raws of table.

For example iterator makes 5 iterations, I get 5 rows (<tr>some
content</tr>), but I want to set id attribute for them:
<tr id="MyGeneratedRow0">some content</tr>
<tr id="MyGeneratedRow1">some content</tr>
<tr id="MyGeneratedRow2">some content</tr>
<tr id="MyGeneratedRow3">some content</tr>
<tr id="MyGeneratedRow4">some content</tr>

I use this code:
<s:iterator value="lawDraft.docs" id="doc" status="document">
     <s:param name="rawMainDocIdParam" value="attachedMainDocRow<s:property
value="document.index"/>"/>
     <tr id="%{#rawMainDocIdParam}">
          some content
     </tr>
</s:iterator>

The problem is: I'm trying to access status (starts from 0) of iterator,
I've tried
<s:param name="rawMainDocIdParam" value="attachedMainDocRow<s:property
value="document.index"/>"/>
I get error: "No information about attribute tag document.index"
I've tried 
<s:param name="rawMainDocIdParam" value="attachedMainDocRow<s:property
value="#document.index"/>"/>
and
<s:param name="rawMainDocIdParam" value="attachedMainDocRow<s:property
value="%{#document.index}"/>"/>
In both cases I get error "Can't convert to xml document.index"

Any suggestions, please, can't understand mistake.
-- 
View this message in context: http://www.nabble.com/Problem-accessing-iterated-object-%28%3Cs%3Aiterator%29-tp18614028p18685569.html
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: Nothing helps

Posted by Jim Kiley <jh...@summa-tech.com>.
Just as a side note, message subject lines like "Nothing helps" and "A
similar problem" should probably be avoided on this list.  When someone
looks at the archives because they're stumped about a problem with
displaying problems within an iterator, there's no signal that this thread,
for instance, might give them information about their problem.

jk

On Fri, Jul 25, 2008 at 8:35 AM, holod <se...@gmail.com> wrote:

>
> Thank you, I've finally solved the problem! Previous solutions helped me,
> seems like I was making stupid mistakes.
> This code snippet prints links to my download action, my download action
> works fine.
> Thank you again!
>
>
> <s:iterator value="lawDraft.docs" id="doc">
>                                                <s:url id="downloadAction"
> action="DownloadLawDraftDocument"
> namespace="/admin">
>                                                        <s:param
> name="lawDraftId" value="lawDraft.id"/>
>                                                        <s:param
> name="documentTitle" value="title"/>
>                                                </s:url>
>                                                        <tr>
>                                                                <td>
>                                                                        <s:a
> href="%{#downloadAction}">
>
>    <s:property value="title"/>
>
>  </s:a>
>                                                                </td>
>                                                        </tr>
>                                        </s:iterator>
> --
> View this message in context:
> http://www.nabble.com/Problem-accessing-iterated-object-%28%3Cs%3Aiterator%29-tp18614028p18650869.html
> 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
>
>


-- 
Jim Kiley
Technical Consultant | Summa
[p] 412.258.3346 [m] 412.445.1729
http://www.summa-tech.com

RE: Nothing helps

Posted by holod <se...@gmail.com>.
Thank you, I've finally solved the problem! Previous solutions helped me,
seems like I was making stupid mistakes.
This code snippet prints links to my download action, my download action
works fine.
Thank you again!


<s:iterator value="lawDraft.docs" id="doc">
						<s:url id="downloadAction" action="DownloadLawDraftDocument"
namespace="/admin">
							<s:param name="lawDraftId" value="lawDraft.id"/>
							<s:param name="documentTitle" value="title"/>
						</s:url>
							<tr>
								<td>
									<s:a href="%{#downloadAction}">
										<s:property value="title"/>
									</s:a>
								</td>
							</tr>
					</s:iterator>
-- 
View this message in context: http://www.nabble.com/Problem-accessing-iterated-object-%28%3Cs%3Aiterator%29-tp18614028p18650869.html
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: Nothing helps

Posted by Jishnu Viswanath <ji...@tavant.com>.
1.If var does not exist u are using struts 2.0.x not 2.1.x

2. Try doing something like this so this 
<s:iterator value="lawDraft.docs>
<div>one</div>
</s:iterator>
If one prints atleast one time then you have lawDraft.docs exists as a
List

3.
Say u have a classes

Class LawDraftAction{

LawDraft lawDraft;
//Getter setters
}



Class LawDraft{

List<Document> docs;
//Getter Setter
}

Class Document{

String title;
//Getter Setter again :P
}

Then in jsp you can write

<s:iterator value="lawDraft.docs>
	Document Title: <s:property value="title"/>

</s:iterator>


Regards,

Jishnu Viswanath

Software Engineer

*(+9180)41190300 - 222(Ext) ll * ( + 91 ) 9731209330ll

Tavant Technologies Inc.,

www.tavant.com

PEOPLE :: PASSION :: EXCELLENCE


-----Original Message-----
From: holod [mailto:serega.sheypak@gmail.com] 
Sent: Friday, July 25, 2008 2:06 PM
To: user@struts.apache.org
Subject: Nothing helps


attribute "var" doesn't exist in my struts-tags.tld. I'm using the last
one
struts2 pack.

lawDraft.docs returns List with 5 elements.
Simple printing </s:property value="lawDraft.docs"> shows 5 elements

I've tried to invoke method "getTitle()" of class Document which
instances
are in ArrayList:
1.
<s:iterator value="lawDraft.docs" status="document" id="doc">
</s:property value ="title">
</s:iterator>
Nothing, empty string

2.
<s:iterator value="lawDraft.docs" status="document" id="doc">
</s:property value ="%{#doc.title}">
</s:iterator>
Nothing, empty string

Previous actions prints to log fields of objects kept in
Lawdraft.getDocs()
I know, that title is not null or empty.

Can you suggest me something else?
-- 
View this message in context:
http://www.nabble.com/Problem-accessing-iterated-object-%28%3Cs%3Aiterat
or%29-tp18614028p18647504.html
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

Any comments or statements made in this email are not necessarily those of Tavant Technologies.
The information transmitted is intended only for the person or entity to which it is addressed and may 
contain confidential and/or privileged material. If you have received this in error, please contact the 
sender and delete the material from any computer. All e-mails sent from or to Tavant Technologies 
may be subject to our monitoring procedures.


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