• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

another design problem with struts 2

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i load up dataParams.jsp from main.jsp:

i map it in struts.xml:

and set up a DataParams-validator.xml.

The problem starts when i submit dataParams.jsp 's form:

because it's supposed to validate while beeing loaded by main.jsp, but it displays alone not included in main.jsp when it displays errors.
The key to this problem is what should i write in <form action="???" to make this work the way i aim?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not really sure what you're asking. Forms should submit to the action and method name you want to process the submission. You have the "input" result mapped to the dataParams.jsp page--if that's not what you want to display then you should map the input result to something else.
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If i dataParams action doesn't get called when dataParams submits, the struts 2 xml validation doesn't fire.
dataParams.jsp is supposed to be always included in main.jsp though, showing errors or not,
but if i call main action, the struts 2 xml validation is always bypassed by the input action.
dataParams bypasses validation the first time because it doesn't need to validate when first shown (like in HelloWorld), should i validate from start and live with it?
Maybe action chaining would do it? I don't know...
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Action chaining is even worse than using the <s:action> tag :(
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What's bad about <s:action> tag?

EDIT:1 chaining is not good for me, it only needs to run when validation triggers. I think i'll go back to struts 1
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Struts 1 is even worse than action chaining.

(That one's actually debatable, but S2 is so much better than S1 it's not a very interesting debate.)

Using the action tag basically *is* action chaining, just not on the Java- or config-level. Besides a tricky "gotcha" that IIRC is related to I18N (I don't recall at this point), it ties up dependencies in a way that's arguably even worse than Java- or config-level chaining, because it's essentially invisible unless you happen to see it in the JSP. The possibility of unintended side effects is just too great, particularly since there are other ways to accomplish the same things.
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ActionSupport ties everything togheter from what i can tell so far, interceptors, validation, resource bundles etc. W/o it there isn't much struts 2.
I'm having a tough time with struts 2's 'so much better'ness because:
1. I don't want to learn freemarker at this point, so, struts 2 default xml validation is pointless to me spouting the message where i don't want it to, where as struts 1 outputs the error message in the position i like; of course i can do jsp validation, but then what is struts 2 validation for if i can't use it in my web app.
2. I don't really need POJO's so far as action classes.
3. I don't see how can i come out of a design tight spot like this ATM (the mailing list question returned with "i can't" which i believe). If Struts 2 is so much better how come i end up using JSP's tags almost every time.
4. I don't see what the exact problem of struts 1 is, but its verbose configs kind of work for me.
5. So far looking at struts 1&2 i think it's often better to do JSP with servlets and Beans/POJOs as code behind for MVC.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

1. I don't want to learn freemarker at this point, so, struts 2 default xml validation is pointless to me spouting the message where i don't want it to, where as struts 1 outputs the error message in the position i like; of course i can do jsp validation, but then what is struts 2 validation for if i can't use it in my web app.


What does FreeMarker have to do with the validation? (Nothing.) So create a theme--the point of having extensible/modifiable themes is to avoid being locked in to the framework's idea of where you should put things. If learning even *than* much FreeMarker is too much, then I agree--Struts 2 is not for you.

2. I don't really need POJO's so far as action classes.


Nobody else does, either, at least for the most part (people exposing services are more likely to use the POJO functionality).

3. I don't see how can i come out of a design tight spot like this ATM (the mailing list question returned with "i can't" which i believe). If Struts 2 is so much better how come i end up using JSP's tags almost every time.


For that question I have no idea--I sure don't have to use S2 tags in that way, but I might be writing much larger applications that require some extensibility/maintainability than you are. For small apps like that I don't use *any* Java framework--Java's too bulky for easy stuff. At the least I'd consider using a different Java-based framework.

4. I don't see what the exact problem of struts 1 is, but its verbose configs kind of work for me.


Verbose configs are hardly the biggest issue with S1. Testability, extensibility, and maintainability, OTOH, are.

5. So far looking at struts 1&2 i think it's often better to do JSP with servlets and Beans/POJOs as code behind for MVC.


So do that then--nobody's making you use either framework.
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the guidance but i only care for concrete solutions. Nobody is making you commenting my threads w/o coming up with a solution.
Please stop answering my questions if you're going to say "I sure don't have to use S2 tags in that way" and "...nobody's making you use either framework." This is a struts forum I asked about the problem with where default struts 2 validation puts the error message not the relation between FreeMarker and Struts 2 (which exists anyway). Also people don't learn struts to create something new but also maintain existing work. Also i'm using Java frameworks for once because i hope i would benefit for the much acclaimed maintainability of it that comes from templating (which seems to be the main concept of all these frameworks). I dreamed up a solution now that i realised struts 2 can be intermingled with struts 1 and servlets. Hopefully i can materialise it.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Themes exist *specifically* so that people can extend or modify them to suit their application's needs. There's no possible (or at least practical) way we can guess everybody's layout information--so we made it ridiculously easy to change it. The same way we do on the Java side--by abstracting functionality.
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thanks for the guidance but i only care for concrete solutions.


And what is "concrete solutions"??

Tudor Andrei Raneti wrote:5. So far looking at struts 1&2 i think it's often better to do JSP with servlets and Beans/POJOs as code behind for MVC.


Tudor Andrei Raneti wrote:Nobody is making you commenting my threads w/o coming up with a solution.Please stop answering my questions if you're going to say "I sure don't have to use S2 tags in that way" and "...nobody's making you use either framework." .....i'm using Java frameworks for once because i hope i would benefit for the much acclaimed maintainability of it that comes from templating


Doesn't your statements contradict with each other?? Earlier you were saying that its better to do JSP with servlets, and now you are saying that you want to use the features of a framework. If you make 5 points about how struts is not for you, then what is a person supposed to say?? Creating a theme to use struts is much better than handling all request parameters by hand, forwarding from servlets to JSP using request dispatcher, handling all validation by hand .....
 
Tudor Raneti
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't know how it is where you live, but here bosses don't care if a framework can't do this or that, and they are partly right, if the framework can't do something, patch it up.

By a concrete solution i mean an example or steps to accomplish a solution to a given problem.

You only think they are conflicting when they are not, i wouldn't post questions in struts forum if i was going to use JSP/servlets. The advantage of struts frameworks is that it's suppose to make certain steps easier like internationalisation and write less code overall. As for themes vs markup, i understood the markup to put stuff where it should right away in struts, in fact i'm surprised the devs didn't leave an attribute for it. I don't have the time to learn it, and if i had, i'm still dismalled having to learn yet another paradigm to the already flawed paradigm of web developing of having at least 4 languages to do it.

Anyway themes are enforcing a way, whereas the key to success in something new is also leveraging the old way's advantages. Luckily struts 1, 2 and servlets(i think) can intermingle to supplement eachother. IMO struts 2 should've been to struts 1 and servlets what C++ is to C and assembly. I don't know what you meant by "riculously easy" also, from existing documentation there one could extract the logic do make things work like he wants to, but reading through several articles it still isn't clear where should i put the theme, and i know it would take a couple of days getting use to it.
 
Ankit Garg
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tudor Andrei Raneti wrote: Don't know how it is where you live, but here bosses don't care if a framework can't do this or that,


Believe me, bosses are the same here .

By a concrete solution i mean an example or steps to accomplish a solution to a given problem.


I couldn't provide a concrete solution because I couldn't understand your problem, what you exactly want and why you need to use s:action tag to achieve it. I think David understood your problem and he provided you with the correct way of doing it...
 
Screaming fools! It's nothing more than a tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic