wood burning stoves 2.0*
The moose likes Struts and the fly likes cut&paste changes to DispatchAction fail Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "cut&paste changes to DispatchAction fail" Watch "cut&paste changes to DispatchAction fail" New topic
Author

cut&paste changes to DispatchAction fail

Jerome Mrozak
Greenhorn

Joined: Feb 10, 2006
Posts: 13
I have a site using Struts 1.1 that works for my sample orders. I cut and pasted the code to work with sales orders. Most everything works except for one action.

Here is an example of the struts-config.xml file:

<action
path="/sampleOrderNew"
forward="/sampleOrderEdit.do?dispatch=New"/>
<action
path="/sampleOrder"
type="com.halo.portal.sample.SampleOrderShowAction"
name="sampleOrderForm"
scope="session"
validate="false">
<forward name="success" path="/sampleOrder.jsp" redirect="false"/>
</action>
<action
path="/sampleOrderEdit"
type="com.halo.portal.sample.SampleOrderDispatchAction"
name="sampleOrderForm"
scope="session"
parameter="dispatch"
validate="true"
input="/sampleOrder.jsp">
<forward name="success" path="/sampleOrder.do" redirect="true"/>
<forward name="failure" path="/sampleOrder.do" redirect="true"/>
<forward name="saved" path="/sampleOrder.do#jumptoitems" redirect="true"/>
<forward name="sent" path="/thankYouMessage.jsp" redirect="true"/>
</action>

From my ApplicationResources.properties file:

sampleOrder.anchor.newSampleOrder=New

From SampleOrderDispatchAction extends LookupDispatchAction:

protected Map getKeyMethodMap() {
HashMap map = new HashMap();

...

map.put("sampleOrder.anchor.newSampleOrder", "newSampleOrder");
return map;
}

The "New" method is called through Javascript:

javascript:savedpage('/portal/sampleOrderNew.do')

function savedpage(theLink) {
window.location = theLink;
}

and works fine.

I copy my XML section and rework my subclasses of Action and LookupDispatchAction
...

<action
path="/salesOrderNew"
forward="/salesOrderEdit.do?dispatch=New"/>
</action>
<action
path="/salesOrder"
type="com.halo.portal.order.SalesOrderShowAction"
name="salesOrderForm"
scope="session"
validate="false">
<forward name="success" path="/salesOrder.jsp" redirect="false"/>
</action>
<action
path="/salesOrderEdit"
type="com.halo.portal.order.SalesOrderDispatchAction"
name="salesOrderForm"
scope="session"
parameter="dispatch"
validate="true"
input="/salesOrder.jsp">
<forward name="success" path="/salesOrder.do" redirect="true"/>
<forward name="failure" path="/salesOrder.do" redirect="true"/>
<forward name="saved" path="/salesOrder.do#jumptoitems" redirect="true"/>
<forward name="sent" path="/thankYouMessage.jsp" redirect="true"/>
</action>

From my ApplicationResources.properties file:

salesOrder.anchor.newSalesOrder=New

From SalesOrderDispatchAction extends LookupDispatchAction:

protected Map getKeyMethodMap() {
HashMap map = new HashMap();

...

map.put("salesOrder.anchor.newSalesOrder", "newSalesOrder");
return map;
}

When I call the sales order "New" through Javascript:

javascript:savedpage('/portal/salesOrderNew.do')

I don't get good results. The browser says it has displayed salesOrderNew.do. The JSP page is displayed without being filled with ActionForm data. The Action and LookupDispatchAction methods aren't even entered (debug code tells me so).

If I replace the action as so:

<action
path="/salesOrderNew"
forward="/sampleOrderEdit.do?dispatch=New"/>
</action>

I get the sample order page displayed, so the action is working OK.

When I replace the action as so:

<action
path="/salesOrderNew"
type="com.halo.portal.order.SalesOrderNewAction"
name="salesOrderForm"
scope="session"
validate="false">
<forward name="success" path="/salesOrder.do" redirect="true"/>

and create the required SalesOrderNewAction class I get desired results (a new sales order).

So my question is -- why won't my SalesOrderDispatchAction get called?

Thanks,

Jerome Mrozak.
Jerome Mrozak
Greenhorn

Joined: Feb 10, 2006
Posts: 13
I have found my answer. The SalesOrderForm.validate() method was failing. It was being called prior to any SalesOrderDispatchAction method being called, and so returned the input page salesOrder.jsp without a backing SalesOrderForm being available.

Hard to debug because it looks like it is in the Struts blackbox. By substituting destination pages in the forwards, and having *those* work OK, was I able to narrow down where the failure was occurring.

Jerome.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: cut&paste changes to DispatchAction fail
 
Similar Threads
Disable button from code???
LookupDispatchAction Query
Reg : missing resource 'Vista' in key method map
Request[/sacCustomReports] does not contain handler parameter
Dispatch VS LookupDispatch