If it's an array of strings, you don't need to have *anything*--the property tag will display the top-most value stack value by default. If the cities are an object, the property tag's value attribute should be the name of the city property you want to display.
Pradeep Adibatla
Ranch Hand
Joined: Oct 27, 2009
Posts: 336
posted
0
It is an Arrayist of objects like...
say Australia,
sydney,hobart,Adelaide...
so now what would property take as I have put hem in a session and iterate?
If the cities are an object, the property tag's value attribute should be the name of the city property you want to display.
Pradeep Adibatla wrote:It is an Arrayist of objects like... say Australia,sydney,hobart,Adelaide...
That tells me nothing about what kind of objects they are. Are they strings or not?
like this?
this doesn't work !!!
Correct, it doesn't, because you're using random expressions to try to get it to work, instead of doing what I told you to.
If the objects in the list are strings you don't *need* a "value" attribute in your property tag. If they're objects *containing* a string with the city name, then the "value" attribute should be the name of the object property containing the city's name.
Pradeep Adibatla
Ranch Hand
Joined: Oct 27, 2009
Posts: 336
posted
0
oops actully yes...
I declared the ArrayList like this
Why get the entrySet? You're already iterating over a map, no?
So how is the map being filled? It'd be a *lot* quicker if you'd post everything related. It's clearly *something* you're doing wrong, and I'd rather just get it all dealt with at once rather than drag this out over days.
Lucas Grijander
Greenhorn
Joined: Feb 10, 2009
Posts: 9
posted
0
first you have to create a List with all the cities you want to be displayed
second, in your jsp use just <s:iterator list="yourList"/>
this only work if the objects of your list are Strings
Please make sure that posts help solve the problem--we're already past that point, not dealing with a list, not dealing with simple objects, and so on.
Pradeep Adibatla
Ranch Hand
Joined: Oct 27, 2009
Posts: 336
posted
0
Even this is a error....
actually in the jsp there is a textfield and a button (OK) next to it followed by select box...
The user enters the Country name and click 'ok' button next to it.
Then I do an Ajax call sending the country name from javascript to action class...
Now on recieving the country name I get all the cities in that country using my 'City' class ( the code I wrote earlier) and I am populating in the select box...
Hope it's clear.Is it a wrong process to populate like that? kindly explain...
You mean you're trying to populate a field on the page you're on by making an Ajax request?
If so, that most certainly won't work--the entire page you're on is rendered before anything else happens, that's just how web applications and JSP work--everything in the JSP happens on the server side. If you want to make an Ajax request and populate a field on the current page then you'd need to write the JavaScript to actually *do* that.
Pradeep Adibatla
Ranch Hand
Joined: Oct 27, 2009
Posts: 336
posted
0
Hey ! Thanks David.Now I know the reason...
The reason why I am making an Ajax request is to get the cities of the country selected! If there are alternative ways then I could be extremely happy to know!
If you want to make an Ajax request and populate a field on the current page then you'd need to write the JavaScript to actually *do* that.
What should be my next step.What should the javascript contain and what will be the way to populate it?
How to do it depends on the JavaScript framework you're using.
Pradeep Adibatla
Ranch Hand
Joined: Oct 27, 2009
Posts: 336
posted
0
I havn't used any framework .It's normal javascript.If somethng like Jquery or Dojo gives comfort,I would jump on them but I am desperate to finish this!!!
Ajax is too big a subject to cover in a forum post. Heck, entire books are written on the subject. I suggest grabbing such a book or finding an online tutorial.
It'll be quicker to spend the 10-15 minutes necessary researching how to do this in a JavaScript library than to try to write and debug it by hand in a way that works across browsers.
Pradeep Adibatla
Ranch Hand
Joined: Oct 27, 2009
Posts: 336
posted
0
Yeah that how to do that part is void for me here.I am stuck...now what sould be done in JS?
If you want some code example, download the code for my jQuery in Action book and look in the code examples for chapter 8. The code, of course, assumes that you will use jQuery.
Pradeep Adibatla
Ranch Hand
Joined: Oct 27, 2009
Posts: 336
posted
0
ok! I have you book "Ajax in Action" and I have been trying to do this using Json...
I added json 0.32plugin jar...
added the mapping in struts.xml
I tried to convert that into Json array...
I couldn't proceed further! Kindly provide some direction... I will work over your suggestion.
I gave you a direct link to sample code. How much simpler can we make it?
Pradeep Adibatla
Ranch Hand
Joined: Oct 27, 2009
Posts: 336
posted
0
Thanks, David and Bear for those inputs.
Like in this example...
Looks superb,you could see a "select.php" there.
I was wondering how it would be in struts2 after having prepared the json object as shown in my code.I was talking about an example with struts2 which I thought I couldn't find out beacause jquery and php(atleast for the example) are unknown to me so still coming to terms with them .
I think i would need to change that "select.php" to "cityAction.action"
Now if I try to modify this according to my one,I could do this...
But I don't know what the above one does...
I am fighting it out and will continue till I do so !!!
Pradeep Adibatla
Ranch Hand
Joined: Oct 27, 2009
Posts: 336
posted
0
After the Ajax call is made on selecting the country,I passed the country.Now,I have got this in my Action class...
and this in jsp...
how should I proceed now?? what are the corrections?
I have a button 'tab' which takes me to tabtest.jsp which contains the 2 select boxes...
Now the problem is before I go to tabtest.jsp to select a country,when i click the button 'tab'(as said above) I get a window and I have no clue about this....
<s:form ... is not valid HTML. If this is a Struts question, this is not the place to ask it. If it's an HTML question, don't show Struts markup here.>
Pradeep Adibatla
Ranch Hand
Joined: Oct 27, 2009
Posts: 336
posted
0
Bear,please move it to struts forum...I initially posted this is struts forum...