I've converted a downloadservice from my tap3 app to tap4 and am
running into an issue that I didn't have before. I've used the chart
example from the Workbench to set up the service. I have a tableview
component in which a multiple files can be downloaded.
This is the exception I get:
Unable to read OGNL expression '<parsed OGNL expression>' of
[EMAIL PROTECTED]/docTable]: source is null for
getProperty(null, "filename")
binding: ExpressionBinding[CompanyProfile/docTable
components.tableRows.tableRow.filename]
location: context:/WEB-INF/DocumentTable.jwc, line 31, column 58
26 </component>
27 <component id="downloadLink" type="DownloadLinkComponent">
28 <binding name="documentLockerId"
29 value="components.tableRows.tableRow.id"/>
30 <binding name="documentLockerFilename"
31 value="components.tableRows.tableRow.filename"/>
32 </component>
33 <component id="filenameText" type="InsertText">
34 <binding name="value" value="components.tableRows.tableRow.filename"/>
35 </component>
36 <component id="deleteLink" type="DirectLink">
ognl.OgnlException
source is null for getProperty(null, "filename")
Stack Trace:
ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1611)
ognl.ASTProperty.getValueBody(ASTProperty.java:96)
ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
ognl.SimpleNode.getValue(SimpleNode.java:210)
ognl.ASTChain.getValueBody(ASTChain.java:109)
ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
ognl.SimpleNode.getValue(SimpleNode.java:210)
ognl.Ognl.getValue(Ognl.java:333)
ognl.Ognl.getValue(Ognl.java:310)
org.apache.tapestry.services.impl.ExpressionEvaluatorImpl.readCompiled(ExpressionEvaluatorImpl.java:91)
$ExpressionEvaluator_10733ea1e71.readCompiled($ExpressionEvaluator_10733ea1e71.java)
org.apache.tapestry.binding.ExpressionBinding.resolveExpression(ExpressionBinding.java:110)
org.apache.tapestry.binding.ExpressionBinding.getObject(ExpressionBinding.java:103)
org.apache.tapestry.binding.AbstractBinding.getObject(AbstractBinding.java:87)
$DownloadLinkComponent_50.getDocumentLockerFilename($DownloadLinkComponent_50.java)
com.corp.app.view.service.DocDownloaderService.service(DocDownloaderService.java:71)
Here is my DownloadComponent:
<component-specification
class="com.atwcorp.trustedapp.view.components.DownloadLinkComponent"
allow-body="yes"
allow-informal-parameters="yes">
<description>Download Link</description>
<parameter name="documentLockerId" required="true" />
<parameter name="documentLockerFilename" required="true" />
</component-specification>
public abstract class DownloadLinkComponent extends BaseComponent {
private static Log log =
LogFactory.getLog(DownloadLinkComponent.class);
public abstract String getDocumentLockerFilename();
public abstract Long getDocumentLockerId();
protected void renderComponent(IMarkupWriter writer,
IRequestCycle cycle) {
if (cycle.isRewinding()) {
return;
}
IEngineService ies = cycle.getEngine().getService(
DocDownloaderService.SERVICE_NAME);
log.info("Filename = "+ getDocumentLockerFilename());
log.info("ID = "+ getDocumentLockerId());
ILink lnk = ies.getLink(cycle, false, this);
writer.begin("a");
writer.attribute("href", lnk.getURL());
//renderInformalParameters(writer, cycle);
renderBody(writer, cycle);
// w.closeTag();
writer.end();
}
}
Here is my Service:
public class DocDownloaderService implements IEngineService {
private static Log log = LogFactory.getLog(DocDownloaderService.class);
public static final String SERVICE_NAME = "DocDownloaderService";
private LinkFactory linkFactory;
private WebResponse response;
/**
* Create the service link
*/
public ILink getLink(IRequestCycle cycle, boolean post, Object
parameter) {
IComponent component = (IComponent) parameter;
Map parameters = new HashMap();
parameters.put(ServiceConstants.SERVICE, getName());
parameters.put(ServiceConstants.PAGE,
component.getPage().getPageName());
parameters.put(ServiceConstants.COMPONENT, component.getIdPath());
return getLinkFactory().constructLink(cycle, false,
parameters, true);
}
/**
* Creates the service action
* This service retrieves a file out of the database for download
*/
public void service(IRequestCycle cycle) throws IOException {
String pageName = cycle.getParameter(ServiceConstants.PAGE);
String componentId = cycle.getParameter(ServiceConstants.COMPONENT);
IPage page = cycle.getPage(pageName);
IComponent component = page.getNestedComponent(componentId);
DownloadLinkComponent dlc = (DownloadLinkComponent) component;
if(dlc == null){
return;
}
String filename = dlc.getDocumentLockerFilename();
Long docId = dlc.getDocumentLockerId();
if(filename == null || docId == null){
return;
}
.......
}
And here is a portion of the table.jwc that I have the download component in:
<component id="tableView" type="contrib:TableView">
<binding name="source"
value="ognl:page.docList"/>
<binding name="columns">
literal:!type, !title, !description, !filename, =lockerIdColumn
</binding>
</component>
<component id="tableColumns" type="contrib:TableColumns">
<binding name="class" value="literal:columnheader"/>
</component>
<component id="tableRows" type="contrib:TableRows">
<binding name="class" value="beans.evenOdd.next"/>
</component>
<component id="downloadLink" type="DownloadLinkComponent">
<binding name="documentLockerId"
value="components.tableRows.tableRow.id"/>
<binding name="documentLockerFilename"
value="components.tableRows.tableRow.filename"/>
</component>
<component id="filenameText" type="InsertText">
<binding name="value" value="components.tableRows.tableRow.filename"/>
</component>
<component id="deleteLink" type="DirectLink">
<binding name="listener" value="listener:deleteListener"/>
<binding name="parameters"
value="{components.tableRows.tableRow.id, page.pageName,
page.company.id}"/>
</component>
This used to work in tap3 so I'm not sure what has changed to now give
me this null pointer.
--
~chris
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]