Hello
Does struts have a tag to include (or call functions)???
I have the same code in 4 jsps and want to put it on 1 function but looking in the struts documentation i think there is no support to include funtions.
Thanks
-
Includes-Functions in Struts (3 messages)
- Posted by: Fernando del Rio
- Posted on: July 26 2005 05:28 EDT
Threaded Messages (3)
- Includes-Functions in Struts by Duncan Mills on July 26 2005 12:07 EDT
- Includes-Functions in Struts by Paul Morie on July 28 2005 14:35 EDT
- Includes-Functions in Struts by Fernando del Rio on August 03 2005 06:33 EDT
-
Includes-Functions in Struts[ Go to top ]
- Posted by: Duncan Mills
- Posted on: July 26 2005 12:07 EDT
- in response to Fernando del Rio
What do you mean by include-functions? Certainly you can use JSP includes with Struts or look at Tiles as a more capable version of this.
If you mean can you share scriptlets then you cna use the JSP include mechanism for that although if you are going to the bother of using a proper controller framework then you shouldn't really have much Java code in the pages in any case -
Includes-Functions in Struts[ Go to top ]
- Posted by: Paul Morie
- Posted on: July 28 2005 14:35 EDT
- in response to Fernando del Rio
Hi Fernando-
I agree that you shouldn't be using that much Java code in the JSP pages, but if you find that you must, this is what I would suggest doing:
* Create a Java class with the code you need. It should have a no-argument constructor.
* Use the jsp:useBean tag to expose the class to your JSP as a scripting variable.
It is probably not a good idea to go too crazy using this technique, but you should find some way to avoid that cut-and-paste antipattern action you've got going on right now.
For the record, I believe that this is approach is essentially the View Helper pattern.
HTH,
P -
Includes-Functions in Struts[ Go to top ]
- Posted by: Fernando del Rio
- Posted on: August 03 2005 06:33 EDT
- in response to Paul Morie
Thanks a lot!!
At last i rewrote all the page and now is more like a jsp...