I created a simple test component.
<wo:WOForm>
<wo:AjaxSubmitButton action="$print" value="Test"/>
</wo:WOForm>
and
public class AjaxTestComponent extends ERXComponent {
public AjaxTestComponent(WOContext context) {
super(context);
}
public WOActionResults print() {
System.out.println("TEST");
return null;
}
}
This is the result:
Request: <er.extensions.appserver.ERXRequest (<er.extensions.appserver.ERXRequest httpVersion=HTTP/1.1 headers={accept=[text/_javascript_, text/html, application/xml, text/xml, */*], accept-encoding=[gzip, deflate], accept-language=[de-de], connection=[keep-alive], content-length=[65], content-type=[application/x-www-form-urlencoded; charset=UTF-8], dnt=[1], host=[127.0.0.1:53876], origin=[
http://127.0.0.1:53876], referer=[http://127.0.0.1:53876/cgi-bin/WebObjects/LTPDevBase.woa/wo/ICLTPm2D2qPW7jR89Hpw50/4.1.0.0.33.7.7.3], user-agent=[Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/536.30.1 (KHTML, like Gecko) Version/6.0.5 Safari/536.30.1], x-prototype-version=[1.7], x-requested-with=[XMLHttpRequest]} content-length=65 cookies=null userInfo={} storePageInBacktrackCache=true >) method=POST uri=/cgi-bin/WebObjects/LTPDevBase.woa/ajax/ICLTPm2D2qPW7jR89Hpw50/6.1?1379393722978 defaultFormValueEncoding=UTF-8 formValueEncodingDetectionEnabled=NO formValueEncoding=UTF-8 formValues={WOIsmapCoords = ("1379393722978"); 1.1 = ("Test"); wosid = ("ICLTPm2D2qPW7jR89Hpw50"); AJAX_SUBMIT_BUTTON_NAME = ("1.1"); } >
Sep 17 06:55:23 LTPDevBase[53876] ERROR er.extensions.appserver.ERXApplication - Exception caught: <er.extensions.appserver.ERXDirectActionRequestHandler> Couldn't locate action class named 'ICLTPm2D2qPW7jR89Hpw50'.
Extra info: {
"Bundles" = {
"Ajax" = "";
"ERExtensions" = "";
"JavaMemoryAdaptor" = "";
"JavaWebObjects" = "";
"JavaXML" = "";
"JavaJDBCAdaptor" = "";
"LTPDevBase" = "";
"ERPrototypes" = "";
"JavaWOExtensions" = "";
"JavaEOAccess" = "";
"JavaEOControl" = "";
"MySQLPlugIn" = "";
"WOOgnl" = "";
"ERPDFGeneration" = "";
"JavaFoundation" = "";
};
"Headers" = {
"user-agent" = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/536.30.1 (KHTML, like Gecko) Version/6.0.5 Safari/536.30.1";
"accept" = "text/_javascript_, text/html, application/xml, text/xml, */*";
"dnt" = "1";
"content-type" = "application/x-www-form-urlencoded; charset=UTF-8";
"x-requested-with" = "XMLHttpRequest";
"accept-encoding" = "gzip, deflate";
"x-prototype-version" = "1.7";
"content-length" = "65";
"host" = "127.0.0.1:53876";
"accept-language" = "de-de";
"connection" = "keep-alive";
};
"URL" = "/cgi-bin/WebObjects/LTPDevBase.woa/ajax/ICLTPm2D2qPW7jR89Hpw50/6.1?1379393722978";
}
IllegalStateException: <er.extensions.appserver.ERXDirectActionRequestHandler> Couldn't locate action class named 'ICLTPm2D2qPW7jR89Hpw50'.
at com.webobjects.appserver._private.WOActionRequestHandler._handleRequest(WOActionRequestHandler.java:286)
... skipped 5 stack elements
at rsc.ltp.Application.dispatchRequest(Application.java:119)
... skipped 3 stack elements
_ignoredPackages:: ("com.webobjects", "java.applet", "java.awt", "java.awt.datatransfer", "java.awt.event", "java.awt.image", "java.beans", "java.io", "java.lang", "java.lang.reflect", "java.math", "
java.net", "java.rmi", "java.rmi.dgc", "java.rmi.registry", "java.rmi.server", "java.security", "java.security.acl", "java.security.interfaces", "java.sql", "java.text", "java.util", "java.util.zip")
Sep 17 06:55:23 LTPDevBase[53876] INFO er.extensions.appserver.ERXApplication - Session.Session: $SESSION CREATED pGox8DmtqDW6WcH1diziu0
Sep 17 06:55:23 LTPDevBase[53876] INFO NSLog - **************************************
Sep 17 06:55:23 LTPDevBase[53876] INFO NSLog - uri: /cgi-bin/WebObjects/LTPDevBase.woa/ajax/ICLTPm2D2qPW7jR89Hpw50/6.1?1379393722978
So I don't think that the problem is there. I also created a test application. This works with Ajax while I don't use the directActionRequestHandler. I mark them with bigger letters.
Yesterday I also found out that the same problem is with the AjaxObserveField. As I can see in the error message it has something to do with the request handler.
My Application class is this:
public class Application extends ERXApplication {
public static void main(String[] argv) {
ERXApplication.main(argv, Application.class);
}
public Application() {
ERXApplication.log.info("Welcome to " + name() + " !");
/* ** put your initialization code in here ** */
setAllowsConcurrentRequestHandling(true);
String directActionRequestHandlerKey = this.directActionRequestHandlerKey();
WORequestHandler directActionRequestHandler = this.requestHandlerForKey(directActionRequestHandlerKey);
this.setDefaultRequestHandler(directActionRequestHandler);
this.useComponentActionRedirection = false;
this.setSessionTimeOut(1200);
}
public WOComponent pageWithName(String name, ERXWOContext c) {
ERXApplication.log.info("Application.pageWithName\n" + name + "\n" + c.toString());
if (c.senderID() == null && componentRequestHandlerKey().equals(c.request().requestHandlerKey() ) ) {
name = "Main";
}
return (WOComponent)super.pageWithName(name, c);
}
private WOResponse responseForPageWithName(String name, ERXWOContext c)
{
WOComponent component = this.pageWithName( name, c );
WOResponse response = component.generateResponse();
return response;
}
/** @Method handleException
* @return WOResponse
* We catch Exceptions from the server to show our own Exception view
*/
public WOResponse handleException(Exception e, ERXWOContext c)
{
WOResponse response;
response = this.responseForPageWithName
(MyExceptionPage.class.getName(), c ); // We show our own Exception View
e.printStackTrace();
return response;
}
/** @Method handleSessionRestorationErrorInContext
* @return WOResponse
* We catch the Session timeout exception from the server to show our own Session Ended view
*/
public WOResponse handleSessionRestorationErrorInContext(ERXWOContext c) {
WOResponse response = this.responseForPageWithName
(SessionEnded.class.getName(), c );
return response;
}
/** @Method dispatchRequest
* @return WOResponse
* Capture and report the amount of time it takes to handle an action; perhaps for TEST only
*/
public WOResponse dispatchRequest(WORequest request) {
System.out.println("Request: " + request);
long startTime = System.currentTimeMillis();
WOResponse response = super.dispatchRequest(request);
String uri = request.uri();
if (uri.startsWith("/cgi-bin")) {
long elapsedTime = System.currentTimeMillis() - startTime;
NSLog.out.appendln("**************************************");
NSLog.out.appendln("uri: " + request.uri());
NSLog.out.appendln("took: " + elapsedTime + " milliseconds");
NSLog.out.appendln("");
}
return response;
}
And my DirectAction has this but in this class nothing is called when the test button is pressed:
public class DirectAction extends ERXDirectAction {
private String destinationUrl = "destinationUrl";
public String destinationUrl() {
return destinationUrl;
}
/**
* Sets the URL to redirect to when login succeeds.
*
* @param newDestinationUrl the URL to redirect to when login succeeds
*/
public void setDestinationUrl(String newDestinationUrl)
{
destinationUrl = newDestinationUrl;
}
public DirectAction(WORequest request) {
super(request);
}
@Override
public WOActionResults defaultAction() {
return pageWithName(Main.class.getName());
}
/**
* Methode performActionNamed
* This method can be used to run special actions
* @return actionResults
*/
public WOActionResults performActionNamed(String actionName) {
if (actionName.startsWith("appLogin")) {
// Tue hier irgend etwas tolles
return super.performActionNamed("default");
}
return super.performActionNamed(actionName);
}
......