The struts framework stores the Action Errors in the request object and hence when we redirect an action in the struts-config.xml, the errors saved may disappear.
<forward name="close" redirect="true" path="/logoutAction.do" contextrelative="false" >
Solution
Put the errors in session scope as <html:errors/> reads ActionErrors from session context too
Example
private ActionErrors errors = new ActionErrors();
try
{
insertNewEmployee();
}
catch (SQLException e)
{
errors.add(ActionErrors.GLOBAL_MESSAGE,
new ActionMessage("errors.database.unableToInsert"));
}
saveErrors(request.getSession(), errors);
Tuesday, December 4, 2007
Friday, November 30, 2007
Struts StyleId attribute
In HTML, we can make references to an element by the "id" attribute.
Example: input type="text" name="carrier" id="carrierId"
We can reference this element in javascript as document.getElementById("carrierId")
In Struts, 1.1 we do not have this attribute "id". To make a reference we can instead use the styleId attribute
Example: <html:text property="carrier" styleId="carrierId" />
Example: input type="text" name="carrier" id="carrierId"
We can reference this element in javascript as document.getElementById("carrierId")
In Struts, 1.1 we do not have this attribute "id". To make a reference we can instead use the styleId attribute
Example: <html:text property="carrier" styleId="carrierId" />
Introduction
This site is dedicated to post mostly techincal code samples and informations from my experiences in J2EE and related technologies
Subscribe to:
Posts (Atom)