struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bård Arve Evjen <bardev...@operamail.com>
Subject Exception handling - please help!
Date Tue, 28 Oct 2003 09:36:42 GMT
Hi,

I'm trying hard not to rip out hair from my scalp. I cannot get the exception handling in
struts to work. What am I doing wrong? Please help me before I go insane...

I have an action that contains:

ActionMessages actionMess = new ActionMessages();
ActionMessage error = null;

in the start of the action and:

try {
            ITradeProvider provider = (ITradeProvider) ProviderInit.getProvider(ITradeProvider.class);
            IReportExportProvider reportProvider = (IReportExportProvider) ProviderInit.getProvider(IReportExportProvider.class);

            // Remove values before run
            request.getSession().removeValue(CheckSession.SESSION_REPORTTYPES);

            TradeRec[] trades = provider.fetchTrades(ti);
            TradeHolder th = new TradeHolder(trades);
	    
            request.getSession().putValue(CheckSession.SESSION_TRADES, th);
        } catch (Exception e) {
            if (e instanceof CondicoException) {
                error = new ActionMessage("web.trade.jsp.no.records");
                actionMess.add("trades", error );
            }
            if (e instanceof NullPointerException) {
                error = new ActionMessage("web.trade.jsp.no.records");
                actionMess.add("trades", error );
            }
            error = new ActionMessage("web.trade.jsp.error");
            actionMess.add("trades", error );
            saveMessages(request, actionMess);            
        }

        return mapping.findForward("ResultTrade");

---------
in the jsp-file I have:

<logic:messagesPresent>
    <bean:message key="errors.header"/>
    <html:messages id="error">
      <li><bean:write name="error" property="<%=error%>"/></li>
    </html:messages>
    <hr>
</logic:messagesPresent>

<logic:messagesPresent message="true">
   <html:messages id="message" message="true">
     <bean:write name="message" property="<%=message%>"/><br>
   </html:messages>
</logic:messagesPresent>

-----------
and in the struts-config.xml file:

<action path="/SearchTrades"
            type="com.om.condico.webclient.servlet.SearchTradesAction"
            name="SearchTradesForm"
            scope="request"
            validate="true"
            input="/trade/index.jsp">
            <exception
                key="web.trade.jsp.no.records"
                type="com.om.condico.util.exception.CondicoException"
                path="/trade/result.jsp"/>
            <exception
                key="web.trade.jsp.error"
                type="java.lang.Exception"
                path="/trade/result.jsp"/>
            <exception
                key="web.trade.jsp.no.records"
                type="java.lang.NullPointerException"
                path="/trade/result.jsp"/>
            <forward name="ResultTrade" path="/trade/result.jsp"/>
        </action>

----------

What am I doing wrong?

Cheers,
Bard
-- 
___________________________________________________
OperaMail free e-mail - http://www.operamail.com
OperaMail Premium - 28MB, POP3, more! US$29.99/year

Powered by Outblaze

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message