Results 1 to 11 of 11
- 11-07-2010, 02:16 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 5
- Rep Power
- 0
Dynamic check box creation + Ajax
I have to create multiple check boxces dynamically depends on the selection of the drop down box. We are developing Struts application and wanted to implement Ajax to dynamically load the page with check boxces (html:multibox). I am looking for the help how to handle this situation?
Idon't have the code to post it here.
It would be appreciate if any one can help me on this.
Thanks in advance,
Rama.
- 11-07-2010, 04:03 PM #2
Senior Member
- Join Date
- Dec 2009
- Location
- Belgrade, Serbia
- Posts
- 364
- Rep Power
- 4
What exactlly is you don't know about this? Is it a ajax function, or you know ajax and you just need to place a right call to struts so confuses you how? Are you gonna put this on some JSP that is 'view' or you need it on 'form'?
- 11-08-2010, 03:30 PM #3
Member
- Join Date
- Nov 2010
- Posts
- 5
- Rep Power
- 0
Thanks for the quick response.
I know Ajax and wanted to write an Ajax statement in the JSP to set the String[] (which consistes of array of String values for the check boxces)coming from the Struts Action to the ID/Name of the <html:multibox> tag defined in the same JSP.
I hope I didn't confuse you.
Thanks,
Rama
- 11-08-2010, 05:02 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
The struts code (and tags) is executed on the server.
Your Ajax calls are made on the client.
Your Ajax call needs to use Javascript to create checkboxes...it can't use Struts tags to do that.
- 11-08-2010, 07:31 PM #5
Member
- Join Date
- Nov 2010
- Posts
- 5
- Rep Power
- 0
ok..understand..
can I get sample code to create the check boxces dynamically with Javascript and the scriplet of the JSP code to define/declare the html checkbox/multibox ?
Thanks,
Rama
- 11-09-2010, 08:57 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Actually, rereading this, I'm not sure what it is (functionally) you want. What is the user going to see when the page loads up? When is this Ajax call being made, and what then happens to the clients window?
- 11-09-2010, 04:16 PM #7
Member
- Join Date
- Nov 2010
- Posts
- 5
- Rep Power
- 0
ok..let me explain in detail.
In the JSP,when the page load,it will show only a drop down box.If select a value from the drop down,I wanted to make Ajax call to Struts Action to get the String[] (ex: Onion,Tomato,Cheese for selectedPizza from the drop down)and dynamically create the checkboxces in the JSP.
- 11-09-2010, 04:40 PM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Ah...this is the thread I'm mixing up with the shuttle thing, for some unkown reason!
OK, so user selects someting in drop down.
That something is associated with a certain collection of checkboxes (ie options).
I'm not sure how multibox works, but would you plan on having one multibox collection per drop down selection? Or indeed, can you?
That would give you your Struts mapping between fields. Have all of those on the page, in named <div>s. Hide all the divs. On select, show the relevant div.
This is off the top of my head at the end of a long day, so take it with a pinch of salt.
- 11-09-2010, 05:58 PM #9
Member
- Join Date
- Nov 2010
- Posts
- 5
- Rep Power
- 0
Yes Tolls ..your understanding is right.
I implemented show/hide logic to display/not diaply content in the JSP when onload the page.Now I need to have a piece of Javascript which will generate the check boxces(may not be a Struts <html:multibox>) and Java scriplet to define the <div id= " "> tag in the JSP depends on the selectedItem from the drop down.
- 11-10-2010, 08:47 AM #10
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
You don't need to define the checkboxes.
You should have something like (syntax may be a bit out, as I don't know the syntax for multibox):
So that gives you a unique multibox for each opf the drop down entries. All your code then has to do is show/hide onChange() of the drop down. And that bit you'll have to do since that's Javascript.Java Code:for each thing in the drop down <div id="some reference to the drop down value"> <html:multibox (same reference here?)/> </div>
- 11-10-2010, 09:46 AM #11
Senior Member
- Join Date
- Dec 2009
- Location
- Belgrade, Serbia
- Posts
- 364
- Rep Power
- 4
You have dropdown list of Pizzas.
When you select one Pizza, you want ingredients for that Pizza to show up.
Each ingredient is checkbox so you can choose to put it or not on your pizza.
Is this valid description of what you are doing?
First, in you have your pizza/ingredient static catalog, why simply not load it all on client, and let JS solve dependencies and show proper ingredient for pizza you choose, all on one page without reload or ajax calls?
If you think it is too much data to load, or you are simply Ajax fan, do it your way. Here is a link to clear things up about multibox in Struts:
http://www.laliluna.de/download/stru...ultibox-en.pdf
Tolls is right - no checkbox creation in JS - you do that in
multibox and you will find in previous link iteration example, all you have to do it create reference between pizza and its ingredients.
Similar Threads
-
JVM creation failed
By RogerP in forum NetBeansReplies: 12Last Post: 10-08-2011, 09:33 PM -
Dynamic creation of custom filter based on the columns visible in the tableColumnHead
By neha_sinha in forum AWT / SwingReplies: 5Last Post: 07-09-2010, 06:14 AM -
dynamic tree creation in jsp
By rummy in forum JavaServer Pages (JSP) and JSTLReplies: 5Last Post: 01-11-2010, 12:25 PM -
dynamic creation of jpanel
By masa in forum AWT / SwingReplies: 1Last Post: 12-18-2008, 11:36 AM -
bmp creation
By makpandian in forum New To JavaReplies: 1Last Post: 12-17-2008, 05:33 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks