This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Micro Frontends in Action and have Michael Geers on-line!
See this thread for details.
Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Difference between action and forward attribute in html:link tag

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is it, when I use html:link tag's action attribute, I get my form validated on the initial view (for the first time) and if I use html:link tag's forward attribute, I don't get that behaviour?

I am using Struts 1.3.8.
I am using modules
I am using Tiles
I am using Struts Validator
My folder structure looks like this:
WebContent/index.jsp
WebContent/employee/index.jsp
WEB-INF/struts-config-employee.xml
WEB-INF/struts-config.xml
WEB-INF/web.xml
WEB-INF/validation.xml
WEB-INF/tiles-defs.xml

This is the code when I use "forward" attribute:
index.jsp:

• <html:link forward="viewAddEmployee"><bean:message key="link.employee.add"/></html:link><br>

struts-config.xml:
<global-forwards>
<forward name="viewAddEmployee" path="/employee/admin/viewAddSearch.do" />
</global-forwards>


struts-config-employee.xml:
<action path="/admin/viewAddSearch" forward="addEmployee.page"/>

tiles-defs.xml:
<definition name="addEmployee.page" extends="main.layout">
<put name="title"
value="ABC, Inc. Human Resources Portal - Employee Search"/>
<put name="body" value="/employee/admin/addEmployee.jsp"/>
</definition>

addEmployee.jsp:
<html:errors/>

When I run the application like this I don't get the validation on initial run (this is ok - I want this).

But when I use the "action" attribute:
index.jsp:
• <html:link action="/employee/admin/addEmployee"><bean:message key="link.employee.add"/></html:link>

struts-config-employee.xml:

<action path="/admin/addEmployee"
type="org.jamesholmes.minihr.AddEmployeeAction" name="addEmployeeForm"scope="request" validate="true" input="addEmployee.page">
</action>

tiles-defs.xml:
<definition name="addEmployee.page" extends="main.layout">
<put name="title"
value="ABC, Inc. Human Resources Portal - Employee Search"/>
<put name="body" value="/employee/admin/addEmployee.jsp"/>
</definition>

addEmployee.jsp:
<html:errors/>

If you need the validation.xml I can send it too.
This way I get the validation done on the initial run. Can anyone explain to me why? I guess I don't have to always use forward but I don't know how this could be fixed.

Thanks in advance!
 
Evildoers! Eat my justice! And this tiny ad's justice too!
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic