Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Avoiding html forms in a struts application

 
Joe May
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I was just wondering if there is anyway to design a struts application without using html forms. Any kind of pointers towards such a design would be greatly appreciated

Thanks a ton,
Mec
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, just don't use any forms.

That seems like a really bizarre thing to ask, though.
 
Joe May
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,

Lets say I have a normal 3 tier application - model ,view and controller. If I do not use forms, how would i pass data without a form submit from my view to my controller? Basically I am trying to make the app totally ajax driven and avoid form submits. But where would I store the data? Only thing I can think of is Http session. Is that advisable. Would it not be unneccessary use of memory? Is it a bad design? and is there a better way?

Thanks
Mec
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even Ajax submits are still form submits, they're just made via Ajax.
 
Joe May
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay,

So are you telling me that If i load a jsp that doesnt contain a form, I will not be able to make a XmlHttpRequest from that page? Okay, I'll read up on that one.. But even then, lets say I load up all the data on the screen using my HttpRequest(I dont have a form bean) and I dont use forms... how will i get the data back in my controller?
 
Joe May
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont have a concrete design in mind but this is wat i am kind of thinking of..

I'll have a Bean. say X.. it ll contain a list of AttributeVO objects... and AttributeVO will contain some member vars like label name,displayElementType, hidden,readonly,disabled etc.... basically all html attributes... And with this attributeVO, i ll draw my jsp.. but now.. i dont wanna use forms and submit it back.. sorry if i seem very confused.... its just a few ideas in mind... not taken shape yet..
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mec fou wrote:So are you telling me that If i load a jsp that doesnt contain a form, I will not be able to make a XmlHttpRequest from that page?

Uh, no, I'm saying even an Ajax request with parameters is still a form submission, made via Ajax.
But even then, lets say I load up all the data on the screen using my HttpRequest(I dont have a form bean) and I dont use forms... how will i get the data back in my controller?

A request, either GET with params in the URL, or a POST. That's the *ONLY* way data gets back to the server--how else could it?

I think you need to do some background reading before you move forward much further--so far you're just describing a regular web app that's using Ajax, so I'm not sure where the issue is.
 
Joe May
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, this is the issue...
1) our application gets frequent changes.... and there are too many rules... like if one attribute is changed on a page, many other attributes have to change... like.. say i select a value from a drop down... it changes multiple things across the screen. So all these rules need a lot of hard coded JS code.
2) Implementing validations was quite a pain. We wanted the errors to show up on top of the screen and change the background color of the field that failed validations. All this was totally hard coded js code and the code now looks really complex and very difficult to modify.

I am just trying to implement a design that is gonna be as db driven as possible.. all the rules come from DB or something... and the application just reacts to all changes easily...
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That seems completely unrelated to the Ajax part.

If this isn't Struts-related I'm going to move it to a different forum, I'm just not sure which one, because I have no idea what you're asking.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You seem to have two topics going here:

1) Forms and Ajax are mutually exclusive (nonsense, by the way)

2) The on-page JavaScript is complex

Seems to me that both issues can be solved with the use of a full-features JavaScript library like jQuery, which allows you to vastly simplify on-page script, and to easily make form submits via Ajax.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic