XForm.completeXForm( XForm.OUTPUT_HTML_PAGE, RuntimeContext.PARAMETER_FORM, xformHeader, new StringBuffer(
parameterTemplate ), getSession(), resolver );
if ( RuntimeContext.debug ) {
debug( Messages.getInstance().getString( "RuntimeContext.DEBUG_PARAMETER_HTML", html ) ); //$NON-NLS-1$
}
IContentItem contentItem = outputHandler.getFeedbackContentItem();
contentItem.setMimeType( "text/html" ); //$NON-NLS-1$
OutputStream os = contentItem.getOutputStream( getActionName() );
os.write( html.getBytes( LocaleHelper.getSystemEncoding() ) );
os.close();
} else if ( parameterXsl.endsWith( ".xsl" ) ) { //$NON-NLS-1$
String id = actionSequence.getSequenceName();
int pos = id.indexOf( '.' );
if ( pos > -1 ) {
id = id.substring( 0, pos );
}
// make sure the id can form a valid javascript variable or
// function name
id = id.replace( '-', '_' );
id = id.replace( ' ', '_' );
String actionUrl = urlFactory.getActionUrlBuilder().getUrl();
String displayUrl = urlFactory.getDisplayUrlBuilder().getUrl();
// String target = (parameterTarget == null) ? "" : parameterTarget; //$NON-NLS-1$
XForm.completeXFormHeader( RuntimeContext.PARAMETER_FORM, xformHeader );
Document document =
XmlDom4JHelper
.getDocFromString(
"<?xml version=\"1.0\" encoding=\"" + LocaleHelper.getSystemEncoding() + "\" ?><filters xmlns:xf=\"http://www.w3.org/2002/xforms\">" + //$NON-NLS-1$ //$NON-NLS-2$
xformHeader
+ "<id><![CDATA[" + //$NON-NLS-1$
id
+ "]]></id><title><![CDATA[" + //$NON-NLS-1$
Messages.getInstance().getEncodedString( actionSequence.getTitle() )
+ "]]></title><description><![CDATA[" + //$NON-NLS-1$
Messages.getInstance().getEncodedString( actionSequence.getDescription() )
+ "]]></description><icon><![CDATA[" + //$NON-NLS-1$
actionSequence.getIcon() + "]]></icon><help><![CDATA[" + //$NON-NLS-1$
Messages.getInstance().getEncodedString( actionSequence.getHelp() ) + "]]></help>" + //$NON-NLS-1$
"<action><![CDATA[" + actionUrl + "]]></action>" + //$NON-NLS-1$ //$NON-NLS-2$
"<display><![CDATA[" + displayUrl + "]]></display>" + //$NON-NLS-1$ //$NON-NLS-2$
( ( parameterTarget != null ) ? "<target>" + parameterTarget + "</target>" : "" ) + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
xformBody.toString() + "</filters>", null ); //$NON-NLS-1$
// add any subscription information here
Element root = document.getRootElement();
// notify the xsl whether we're in parameter view or not.
root.addAttribute(
"parameterView", ( getOutputPreference() == IOutputHandler.OUTPUT_TYPE_PARAMETERS ) ? "true" : "false" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Map<String, String> parameters = new HashMap<String, String>();
parameters.put( "baseUrl", PentahoSystem.getApplicationContext().getBaseUrl() ); //$NON-NLS-1$
parameters.put( "actionUrl", this.getUrlFactory().getActionUrlBuilder().getUrl() ); //$NON-NLS-1$
parameters.put( "displayUrl", this.getUrlFactory().getDisplayUrlBuilder().getUrl() ); //$NON-NLS-1$
// Uncomment this line for troubleshooting the XSL.
StringBuffer content =
XmlHelper.transformXml( parameterXsl, getSolutionPath(), document.asXML(), parameters, resolver );
IContentItem contentItem = outputHandler.getFeedbackContentItem();
contentItem.setMimeType( "text/html" ); //$NON-NLS-1$
OutputStream os = contentItem.getOutputStream( getActionName() );
try {
os.write( content.toString().getBytes( LocaleHelper.getSystemEncoding() ) );
} finally {
if ( os != null ) {
os.close();