This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Why no forward attrib on html:form in Struts?

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why does the html:link tag have a forward attribute (and so can leverage the logical mapping feature of a forward defined in a global forward section) and yet the html:form doesn't? Is it because a given action mapping is more tightly bound to the specific action that handles it? That is a form with its parameters needs to be more tightly bound to a action due to the ActionForm association?
I'm wondering because Husted has said that one of the things he was trying to achieve in Stuts was to decouple pages linkage by introducing a logical mapping that may be modified in an external configuration file. The fact that this feature would appear to be only available for anchor links and not for forms seems inconsistent.
[ April 18, 2004: Message edited by: Sean Walker ]
[ April 18, 2004: Message edited by: Sean Walker ]
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most Struts tags get converted into html. The action attribute of html:form gets converted into the action attribute of html - which has nothing to do with Struts, let alone Struts Actions.
In html an "action" can post to anything it wants. It doesn't have to be a Struts Action.
Hope this helps answer your question.
 
Sean Walker
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By your reasoning then, the html:link tag shouldn't have a forward attribute either, because it expands to an html anchor tag's href attribute (i.e. <a href="..."> ). While in principle I agree that there is no reason to change the name of an attribute if there is no significant semantic abstraction going on, but the forward indirectiona abstraction is significant.
In any case, I maintain that the html:link tag's forward attribute (and it's resulting support for global forwarding behaviour) is inconsistent with the html:form tag's lack of this same indirection abstraction and I wonder why this is so.
Am I missing something? Perhaps it's the fact that a form tag's action relationship to a handler in a Web application is a more necessarily tightly bound relationship than is so with anchors, so only in the case of achors is the indirection of an action forward supported.
I'd love to hear more voices on this...
[ April 19, 2004: Message edited by: Sean Walker ]
[ April 19, 2004: Message edited by: Sean Walker ]
 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you read a bit too much into what I said. I was merely pointing out that the action attribute of html:form is directed at what it is mapped to in html. I pointed this out because it seemed that your whole reason for bringing up the topic was because html:form and html:link both have an action attribute but only html:link has a forward attribute.
Anyway, let's put all that aside for right now.
Why do you think it would add value to submit a form through a global forward? It makes sense for a link because you could have a logout forward or something along those lines. For submitting a form, however, I don't see much value in this. Perhaps you could enlighten me with a scenario where this would be valuable.
 
Sean Walker
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, as I understand them, the whole point of forwards is to provide a configuration driven logical mapping for the linkages between pages within web application. Although there are likely many reasons why this is desireable, two primary ones I believe are that it makes maintenance easier (if you want to change the page transitions to a given page you can change it in one place -in the struts config file- instead of in every preceding page where the link is defined) and that it collects into one document the entire workflow between pages of a web application.
(Although, frankly, this is a little confusing for me because the action mappings also seem to provide this same configurable logical indirection and descriptions via their path attributes, which is effectively a logical name for page linkage).
As far as a concrete example goes, lets picks your's. Let's imagine that we have a log out link in our web application. Initially it is just a link because (ie html:link) there was no need to parameterize the action in the previous cut of this hypothitical application. But now, we want to change it from being a simple anchor into a mini form that has a checkbox field in it that allows the user to specify whether they want to retain or drop their session's shopping cart state upon logout.
So why in this case would we not want the same ability to control and document how the transition should occur?
Perhaps another way of looking at this situation is, why is it that when the activity linking the pages wasn't parameterized (ie an anchor was used) you see value in the use of a logical forwarding mechanism, but when the activity is parameterized (ie a form is used) you don't see value in the use of a forwarding mechanism?
Again there may well be a good reason here, I'm not a web development guru so I may very well be missing something.
[ April 22, 2004: Message edited by: Sean Walker ]
 
Sheriff
Posts: 15813
264
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMO, the difference is in the way the two tags work.
Rendering the html:link tag is pretty straightforward. The forward and action attributes are conveniences that justify using a custom tag rather than plain old html.
The html:form tag, however, has more dependencies since it acts as a container for html:input tags and other similar tags. Remember that Struts can pre-populate the contained tags with values from an ActionForm. It can do this because it can use the value of the action attribute to find the associated ActionForm. There is no such association between a Forward and the ActionForm so how would Struts know what ActionForm to use to prepopulate contained tags?
Perhaps you can give an example of how you think it would be useful to allow the html:form to submit to a forward mapping?
 
Sean Walker
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While I would agree that the form tag needs to resolve a reference to its action mapping in order to determine things like which action form bean is mapped to it, etc, the use of global action forwards wouldn't hamper this at all. Just as it doesn't hamper the html:link tag from ultimately resolving itself to a action mapping path (i.e. /webAppName/moduleName/actionpath.do) So, if the form tag were to support global forwards it would also do this and therefore be able to determine which action mapping to use. Recall that the action mapping are looked up via this URL.
I have already sort of given an example of why you might want to use global forwards with form tags earlier in this thread, but let me make it a little more conrete.
Imagine that you have several pages that have variations of the same form on them (with perhaps different hidden field to give an action a hint) and for all of them you want to use a single action mapping. Now, for some reason, we want to change the path associated with this action mapping. This means that we'll need to go and change the action attribute values in all of the forms that we've used it in. But this is one of the reasns that Husted said he chose to use global forwards. Namely, so that for several links to a given page that span multiple refering pages, you can modify them collectively in terms of the path they link to by modifying the global forward they refer to.
[ April 23, 2004: Message edited by: Sean Walker ]
 
Junilu Lacar
Sheriff
Posts: 15813
264
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aside from shielding you from a change in the logical name itself, I don't see any point in adding another layer of abstraction to what is already an abstraction. The value of the action attribute in the html:form is already a logical name. If you need your form to be processed by another Action, you just change the action mapping's class attribute. If you need to change the form class used to receive request parameters, just change the name attribute in the action mapping.
The whole point of using a logical name (e.g. forward and action) in the first place is to shield you from changes in the thing it represents. Should the framework shield you from changes in the logical names themselves? While perhaps possible, IMO the extra layer of indirection doesn't add that much value and supporting it would have its own issues. What if a forward points to an action that uses the forward itself? What if the forward isn't pointing to an action mapping?
 
Sean Walker
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I agree with your point about the apparent redundancy of the use two layers of indirection (global forwards & action mappings)- see my bracketed comment above in an earlier response to Marc Peabody. But your point seems to hold for both the case of form configuration and anchor confugration.
I just assumed that the eminently competent designers behind Struts had good reason for global forwards and so assumed that I was missing something regarding why they chose to use two logical indirection mechanisms for anchors. And so, by extension, I wondered why they didn't choose to do the same for forms.
Do you think it makes sense in the case of anchors and not in the case of forms?
    Bookmark Topic Watch Topic
  • New Topic