• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

spaces while populating using s:iterator

 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am populating an ArrayList in a select(<select>) tag using s:iterator but when it is populated there is gap between each item in the list...

why is that so? I even tried trimming the values before they are added to ArrayList...

The output looks like...


-----------------------
apple

guava

mango
-----------------------

instead of...

----------------
apple
guava
mango
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think we'll need to see the code to know the problem. The s:select tag allows you to directly specify an iterable source which would be used to generate the select tag (with options inside) automatically...
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used the simple select tag...

This is the code...

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where are you seeing the newlines again?
 
M Turner
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that whitespace exists where <s: tags /> used to be. Therefore, if you populate your <select> using the <s:select /> itself instead of the iterator your problem may be solved.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still confused. If the whitespaces are in the emitted HTML, who cares? If there are empty option elements, then something's broken, because I'm not sure how they could be generated from the code posted.
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure how they could be generated from the code posted.


which is very strange... The problem still persists and I can't use s:select as it would disturb my UI alignment !!!
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not if you used the "simple" theme.

You still haven't explained *where* the spaces are coming. If it's just in the HTML, then it doesn't matter.
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's just in the HTML...

but the gap is of the size of the item in the list,so, a user can actually select the space between the two items which looks odd and also if there are 10 items, the list a 19 item drop down,( 9 spaces between 10 items)so it sort of hampers the UI display!
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you *sure* the list contains what you think it does? It's just not possible for the iterator tag to include objects that aren't in the list.

Note, by the way, that this would be more canonical as:But if you're seeing blank *options*, then it's not "just" in the HTML--it means there are items in the list that aren't displaying.
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But if you're seeing blank *options*, then it's not "just" in the HTML--it means there are items in the list that aren't displaying.


I tried to populate just 2 items say A,B

This is how the dropdown looks like....

-------------
A


B
-------------

instead of ...

--------------
A
B
--------------

may be it's silly but I am unable to solve this one...what else should be the culprit?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the rendered HTML.

A broken list is the only other option: iterator can't iterate over list items that aren't there.
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I can sense a strange thing now...

First up I have an arrayList that contains values...

I am filtering these values by eliminating duplicates and putting them in another ArrayList...


In the above case,the following code would give more clarity...





The output...
-----------------

The conList is :--> [c1, c5, c1, c5]
j is :--> 0
j is :--> 1
The conValues set is :--> c1
The conValues set is :--> c5
The conValues is :--> [c1, c5]
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If there are only two items in the list then the JSP you posted cannot create empty option elements: all the iterator tag does is loop over the collection and run the body of the tag for each element.

Post the rendered HTML, along with the current JSP code.
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey David ...thanks for your patient replies...


It is very frustrating though...you mean this should do?

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, the HTML rendered by the iterator tag--the part you're having a problem with.
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't get that...



Now where should be 'post' inserted??
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
*sigh*

Are you, or are you not, having an issue with your collection and/or iterator tag?
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, I do, but i don't how and where to post the rendered html which you suggested! kindly clarify..
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post it here. Post it by copying and pasting it from the "view source" of your browser. Put it in code tags and disable HTML.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64994
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just do a View Source in the browser! Sheesh.
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whoa! that is some comfusion...I thought I need to "Post" the value somewhere...well,well,here it goes, a bit long and the part to be noticed lurks in the middle...

There are two tabpanels both having same structure and so is for select...

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


No, the ***rendered*** output of the iterator tag--the part you're having the problem with.

"Rendered" means the stuff handed back to the browser, which is why both Bear and I referenced the "view source" thing.
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, here it is...

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64994
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I give up.
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bow down to David's patience

Pradeep, the source that you showed us is of the code that you wrote. Now you open that page in the browser and you get some unusual option elements right. Now when you open the page in the browser, depending upon the browser, do the following
If you are using firefox, go to View menu and there's an option called "Page Source", click on that
If you are using Internet Explorer, go to the View menu and there's an option called "Source", click on that

In both cases you'll see the HTML that the browser got from the server. Copy that HTML and post it here...
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Well,I looked foolish there,but here it is...



 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


At both places you have an opening <option> tag instead of a closing </option> tag...
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
phew! that was one frivolous thing. Mother of all silliest things went on to become most important thread...yeah dats done and dusted.

Thank you all for those patient replies...

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
*lol* Good thing Ankit has sharper eyes than I do ;)

For future reference, when we ask for rendered HTML we usually just mean the parts you're having a problem with, not the entire page.
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
aye aye Sir! Kindly check my other queries...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic