PDA

View Full Version : Filter/Prompt in dashboard / custom JSP???



ingo.klose
03-12-2007, 03:04 PM
Hello,

I use ChartHelper.doAction method to execute a action sequence and display a HTML report. All works fine for regular reports.

But if I execute action sequences that require user inputs, via the filter/prompt component, nothing is returned in the output stream. I would have expected that the HTML for the prompt form is returned.

Does anyone know how to execute an xaction from an custom JSP and display the prompt form if necessary?

Thanks a lot!

All the best,
Ingo

ingo.klose
03-13-2007, 12:36 PM
Hi all,

I have figured it out and would like to share the solution with you.

The doAction function of the ChartHelper class does not set a IUrlFactory and therefore the prompt form can't be rendered. You could extend the ChartHelper class with the following method in order to pass a URL factory and the name of the style sheet to render the form:



public static boolean doAction(String solutionName, String actionPath, String actionName, String processId, IParameterProvider parameterProvider, OutputStream outputStream, IPentahoSession userSession, ArrayList messages, ILogger logger, IPentahoUrlFactory urlFactory, String filterXSL) {

SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, false);
BaseRequestHandler requestHandler = new BaseRequestHandler(userSession, null, outputHandler, parameterProvider, urlFactory);

requestHandler.setProcessId( processId );
requestHandler.setAction(actionPath, actionName);
requestHandler.setSolutionName(solutionName);
if (requestHandler.setParameterXsl(filterXSL) != null){
requestHandler.setParameterXsl(filterXSL);
}

IRuntimeContext runtime = null;
int status = IRuntimeContext.RUNTIME_STATUS_FAILURE;
try {
runtime = requestHandler.handleActionRequest(0, 0);
if( runtime != null ) {
status = runtime.getStatus();
}
} finally {
if (runtime != null) {
runtime.dispose();
}
}
return status == IRuntimeContext.RUNTIME_STATUS_SUCCESS;
}


All you need to do now, e.g. in addition to the code in the SampleDashboard.jsp, is to create the Url factory and pass the name of the XSL:



String baseUrl = PentahoSystem.getApplicationContext().getBaseUrl();
//Action = the name of my custom jsp
SimpleUrlFactory urlFactory = new SimpleUrlFactory(baseUrl+"ViewAction?");
// 2 additional parameters urlFactory and XSL-name
ChartHelper.doAction( "samples", "dashboard/jsp", "embedded_report.xaction", "SampleDashboard", parameters, outputStream , userSession, messages, null, urlFactory, "DefaultParameterForm.xsl");


Don't forget to import the SimpleURLFactory class, too.

I hope this helps in case someone else runs into the same problem.

All the best,
Ingo

gjoseval90
10-25-2007, 03:29 PM
Hello Ingo

I followed your instructions to insert the filter component, but it is not working...
I'm getting this error:



SolutionEngine.ERROR_007 - Action sequence execution failed.

ActionDefinition for SecureFilterComponent did not execute succesfully


If you access the XACTION directly it works.

Any hints?

Thanks in advance

ingo.klose
10-26-2007, 09:28 AM
Sorry,

it worked for me back then but I have not changed anything ever since and so far have not looked at it again.

Can you execute a regular report (without filter)?

Regards,
Ingo

gjoseval90
10-26-2007, 09:36 AM
Yes, I can... Actually the first part of the dashboard is the "Prompt for..." and a bar-chart (which is working normally). Furthermore, all the components are working.

One more question: Have you tried your Dashboard framework with "Prompt" xactions?

Thanks...

Juan

ingo.klose
10-26-2007, 09:52 AM
Hi Juan,

with the framework I have used a different approach. Since it's all AJAX I did not put the prompt in the xaction but build myself little filter"widgets" and pass the selected values via AJAX to the xaction.

This techtip helped me to set this up: http://wiki.pentaho.org/display/COM/Using+AJAX+to+Drive+Dependent+Report+Parameters

Regarding your problem, I just noted something in the JSP code:

SimpleUrlFactory urlFactory = new SimpleUrlFactory(baseUrl+"Action?");

The servlet is called ViewAction and not Action. Maybe that's the problem. I will edit it in the original code.

Regards,
Ingoi

gjoseval90
10-26-2007, 03:08 PM
Hi Ingo

I changed for "ViewAction".....Same result, same error...
Any other ideas?

ingo.klose
10-27-2007, 01:49 AM
Hi,

not really. But you could post the xaction and if I can manage, I will have a look.

One more questions. Does the xaction work without the prompt/filter?

Regards,
Ingo

gjoseval90
10-29-2007, 01:04 PM
Ingo,

The xaction is Attached. As you can see is a simple action, just to prompt for filters. It works if accessed directly, but it does not work when included in dashboard.

Cheers,

Juan



Hi,

not really. But you could post the xaction and if I can manage, I will have a look.

One more questions. Does the xaction work without the prompt/filter?

Regards,
Ingo

ingo.klose
10-30-2007, 01:56 PM
Hi Juan,

I'm very sorry, but I can't even find that version of my system anymore (the origianl post is more than 6 months old). In my special case I ended up not using the doAction()-method but programming the execution in a JSP directly using the request handler object. I can't even remember what the problem was, but I decided, that the method was not feasable for me back then.

Regards,
Ingo