You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Gallagher, Jim (RBoS ITD&S Dublin)" <Ji...@rbs.co.uk> on 2006/11/24 15:45:06 UTC

Problem using LookupDispatchAction

Hi,

	I've persuaded my project team to upgrade from Struts 1.1 to Struts
1.2.9, simply to allow use of the LookupDispatchAction. However, it's not
working correctly for me. Have I misunderstood the requirements, or is there
something else obvious I'm doing wrong? I followed the instructions found in
the Javadoc at
http://struts.apache.org/1.2.x/api/org/apache/struts/actions/LookupDispatchA
ction.html
<http://struts.apache.org/1.2.x/api/org/apache/struts/actions/LookupDispatch
Action.html> 

My JSP (form is scContactCardOptions):

<html:submit value="View Existing Order"
				property="operation" /> &nbsp; <html:submit
				value="orderReplacement"
property="operation" /> &nbsp; <html:submit
				value="Save Service User Number"
property="operation" />


My struts-config.xml:

		<action path="/scContactCardOptions"
type="com.rbsg.application.serviceuserweb.actions.ScContactCardOptionsAction
" name="scContactCardOptionsBean" parameter="operation">
			<forward name="savesuno"
path="ScContactCardPath"></forward>
			<forward name="viewexistingorder"
path="ScContactOrderPath"></forward>
			<forward name="replacementorder"
path="ScReplaceOrderPath"></forward>
		</action>

My action class:

public class ScContactCardOptionsAction extends LookupDispatchAction {

	ActionMessages errors = null;
	ActionForward forward = null;

	/* (non-Javadoc)
	 * @see
org.apache.struts.actions.LookupDispatchAction#getKeyMethodMap()
	 */
	protected Map getKeyMethodMap() {
		System.out.println("executing getKeyMethodMap()");
		Map map = new HashMap();
		map.put("orderReplacement", "orderReplacement");
		map.put("View Existing Order", "viewExistingOrder");
		map.put("Save Service User Number", "saveSUNo");
		return map;
	}

	public ActionForward saveSUNo(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response)
		throws Exception {

		errors = new ActionMessages();
		forward = new ActionForward();
		getUserPreferences(mapping, request);

		ScContactCardOptionsFormBean sssb =
(ScContactCardOptionsFormBean) form;
		String contactID = sssb.getContactID();
		String serviceUserNo = sssb.getServiceUserNo();

		if (errors.isEmpty()) {
			// Forward control to the appropriate 'success' URI
(change name as desired)
			forward = mapping.findForward("savesuno");
		} else {
			// If a message is required, save the specified
key(s)
			// into the request for use by the <struts:errors>
tag.
			saveErrors(request, errors);
		}

		// Finish with
		return (forward);

	}

Further methods called orderReplacement and viewExistingOrder are defined in
an indentical fashion to saveSUNo. 

The exact error message is:

[24/11/06 14:40:21:451 GMT] 6aa82178 DispatchActio E
org.apache.struts.actions.DispatchAction  Action[/scContactCardOptions] does
not contain method named 'View Existing Order'
[24/11/06 14:40:21:451 GMT] 6aa82178 DispatchActio E
org.apache.struts.actions.DispatchAction  TRAS0014I: The following exception
was logged java.lang.NoSuchMethodException:
com.rbsg.application.serviceuserweb.actions.ScContactCardOptionsAction.View
Existing Order(org.apache.struts.action.ActionMapping,
org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse)

Basically, the getKeyMethodMap method does not seem to be executed.

Any assistance would be gratefully received.




                                 Regards,

                                         Jim



The Royal Bank of Scotland plc, Registered in Scotland No. 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB

Authorised and regulated by the Financial Services Authority.

This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. The Royal Bank of Scotland plc does not accept responsibility for changes made to this message after it was sent.

Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by The Royal Bank of Scotland plc in this regard and the recipient should carry out such virus and other checks as it considers appropriate.


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


Re: Problem using LookupDispatchAction

Posted by Wendy Smoak <ws...@gmail.com>.
On 11/24/06, Gallagher, Jim (RBoS ITD&S Dublin) <Ji...@rbs.co.uk> wrote:

>         I've persuaded my project team to upgrade from Struts 1.1 to Struts
> 1.2.9, simply to allow use of the LookupDispatchAction. However, it's not
> working correctly for me. Have I misunderstood the requirements, or is there
> something else obvious I'm doing wrong?

First, EventDispatchAction is a *much* better choice.  Please use that instead.

http://struts.apache.org/1.2.9/api/org/apache/struts/actions/EventDispatchAction.html

(LDA does a reverse lookup from button text to property name and then
(in the key method map,) from property name to method name.  You
didn't show the .properties file, but I doubt your getKeyMethodMap
method is correct as written.  Compare it to the one in the Javadoc.)

-- 
Wendy

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