I gave up my tree barking with that last approach and simply defined a index int with get and sets in my NestedDispatchAction class.

Now when i submit my indexed button

<html:submit property="method" indexed="true">
..

But getMethodName called in my execute method returns null.

null[index]


On 27 Jun 2004, at 17:05, Mark Lowe wrote:

I've got a strange problem where I've extended LookupDispatchAction with my own version and then in turn extended that to create NestedDispatchAction

for one reason or another the getClass method DispatchAction throws a NoSuchMethodException even though its there and works quite happily when not running in my extends LookupDispatchAction.

I've over ridden the execute method i check if the parameter specified in struts xml has a index.

String methodName = getMethodName(mapping, form, request, response, parameter);
int index = 0;
while(enu.hasMoreElements()) {
String target = (String) enu.nextElement();
if(target.indexOf(parameter) != -1 && !target.equals(parameter)) {
int start = target.indexOf("[") + 1;
int end = target.indexOf("]");
index = Integer.parseInt( target.substring(start,end) );
}
}
and then forward to my


return nestedDispatchMethod(mapping,form,request,response,methodName,index);

..

The idea being to just pass the index through in the dispatched methods and thus providing me with a hook to know which nested objects to operate on.

The principle is simple, but this mysterious exception suggests there's something on quite as simple as i perhaps first imagined.

Ideas?


On 27 Jun 2004, at 13:15, Mark Lowe wrote:

The only means i've thought this could be possible would be to iterate through the parameter names enumeration like this..

Enumeration parameterNames = request.getParameterNames();
String parameter = mapping.getParameter();

while(parameterNames.hasMoreElements()) {
        String paramName = parameterNames.nextElement();
        if(paramName.indexOf(parameter) != -1) {
                // find the index using substring
                nestedDispatchMethod([struts gubbins],parameter, index);
        }
}


But given such forms are likely to have a lot of parameter names this would seem a bit heavy going.





On 27 Jun 2004, at 12:42, Mark Lowe wrote:

I've been looking through the struts source with a view to trying to find a way of handling nested dispatch actions.

Basically the problem is passing through an index or key to the getMethodName (MappedDispatchAction) or the getKeyMethodMap (LookupDispatchAction) and running a method based on that.



<html:form action="/foo.do">
<c:forEach var="course" items="${menuForm.courses}" varStatus="firstIndex">
<c:forEach var="nestedLevel" items="${course.dishes}" varStatus="nestedIndex">
<html:text property="${courses[firstIndex.index]. dishes[nestedIndex.index]" />
<html:submit property="method" indexed="true">
..


The situation is that i need to add an item to the the levelOne object. But when submitting there's no way of grabbing the index and thus knowing which of the levelOne objects to add a new rows of nested object to.

So far I've been using the unspecified method and searching the parameter names for a custom button name. So not really dispatching any thing. But If i wanted to go another level i would arrive at the same problem.

So far it looks like adding a nestedDispatchMethod or indexedDispatchMethod which also passes the index through.

Anyone else looked into this? It would seem a common enough problem.

Mark












--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to