Skip to content

Commit

Permalink
Allow simpleClassName in direct action invocation URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
hugithordarson committed Mar 17, 2024
1 parent 312b09e commit a585ca5
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import ng.appserver.NGRequestHandler;
import ng.appserver.NGResponse;
import ng.appserver.privates.NGParsedURI;
import ng.appserver.templating.NGElementUtils;

/**
* FIXME: Currently requires the full class name to be specified.
Expand All @@ -34,13 +35,14 @@ public NGResponse handleRequest( NGRequest request ) {
}

try {
final Class<? extends NGDirectAction> directActionClass = (Class<? extends NGDirectAction>)Class.forName( directActionClassName.get() );
// FIXME: We're using the Dynamic Element class locator to find the class by the simple name. This needs redesign // Hugi 2023-03-17
final Class<? extends NGDirectAction> directActionClass = NGElementUtils.classWithNameNullIfNotFound( directActionClassName.get() );
final Constructor<? extends NGDirectAction> constructor = directActionClass.getConstructor( NGRequest.class );
final NGDirectAction instance = constructor.newInstance( request );
final NGActionResults actionResults = instance.performActionNamed( directActionMethodName.get() );
return actionResults.generateResponse();
}
catch( ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e ) {
catch( /* ClassNotFoundException |*/ InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e ) {
throw new RuntimeException( e );
}
}
Expand Down

0 comments on commit a585ca5

Please sign in to comment.