DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22847>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22847 LookupDispatchAction used with submit using indexed fails ------- Additional Comments From [EMAIL PROTECTED] 2003-08-31 12:33 ------- for the time being I inherited a mew c;ass from LookupDispatchAction and overwrite the execute method like this: I use request.attribute to keep the index value, and I know this is not nice, although for now it's perfect!, working public ActionForward execute( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, Exception { ActionErrors errors = new ActionErrors(); // Identify the request parameter containing the method name String parameter = mapping.getParameter(); if (parameter == null) { String message = messages.getMessage ("dispatch.handler", mapping.getPath()); throw new ServletException(message); } // Identify the string to lookup String name = request.getParameter(parameter); //ADDED BY Isvan Orban 31.08.2003 //if paramter doesn't exist, try to find it as indexed one if (name == null) { String currentParamter; RE r = new RE(parameter+"\\[([0-9]+)\\]"); for (Enumeration i = request.getParameterNames (); i.hasMoreElements() ;) { currentParamter = (String) i.nextElement (); if (r.match(currentParamter)) { name = request.getParameter (currentParamter); // store index value in as Attribute request.setAttribute (INDEXED_DISPATCHPARAM_HOLDER, r.getParen(1)); } } } //handle empty name error if (name == null) { String message = messages.getMessage ("dispatch.parameter", mapping.getPath(), parameter); throw new ServletException(message); } // Based on this request's Locale get the lookupMap Map lookupMap = null; Locale userLocale = getLocale(request); boolean newLookupMap = false; synchronized (localeMap) { lookupMap = (Map) this.localeMap.get (userLocale); if (lookupMap == null) { newLookupMap = true; lookupMap = new HashMap(); this.localeMap.put(userLocale, lookupMap); } } synchronized (lookupMap) { if (newLookupMap) { /* * This is the first time this Locale is used so build the reverse lookup Map. * Search for message keys in all configured MessageResources for * the current module. */ this.keyMethodMap = this.getKeyMethodMap (); ModuleConfig moduleConfig = (ModuleConfig) request.getAttribute(Globals.MODULE_KEY); MessageResourcesConfig[] mrc = moduleConfig.findMessageResourcesConfigs(); // Look through all module's MessageResources for (int i = 0; i < mrc.length; i++) { MessageResources resources = this.getResources (request, mrc[i].getKey()); // Look for key in MessageResources Iterator iter = this.keyMethodMap.keySet().iterator(); while (iter.hasNext()) { String key = (String) iter.next(); String text = resources.getMessage(userLocale, key); // Found key and haven't added to Map yet, so add the text if ((text != null) && ! lookupMap.containsKey(text)) { lookupMap.put (text, key); } } } } } // Find the key String key = (String) lookupMap.get(name); String methodName = (String) keyMethodMap.get(key); return dispatchMethod(mapping, form, request, response, methodName); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
