« Return to Thread: Help using EditLink component

Help using EditLink component

by Chris Mattmann :: Rate this Message:

Reply to Author | View in Thread

Hi Guys,

How are ya? I have a question about the EditLink component. I am trying to
use it to edit an object of type gov.nasa.jpl.edrn.Participant. I have the
following simple code snippet in my Trails application's Home.page:

<p>
<a href="#" jwcid="@trails:EditLink"
 model="ognl:page.persistenceService.getInstance(gov.nasa.jpl.edrn.Participa
nt.class)" >Add a new Participant</a>
</p>

It's hard to find examples of how to use this EditLink component on the web.
I need it though because I don't want to use the ListAllLink component (that
trails uses by default), as I only want to shown certain objects (like the
gov.nasa.jpl.edrn.Participant one) and allow users to add/edit them. By
browsing around different examples, and the FishEye web repo, I thought
maybe the above snippet would work, but it gives me an error (partial stack
trace shown):

org.apache.tapestry.BindingException: Unable to parse OGNL expression
'model': model [classpath:/org/trails/component/EditLink.jwc, line 9, column
30]
        at
org.apache.tapestry.binding.ExpressionBinding.resolveExpression(ExpressionBi
nding.java:145)
        at
org.apache.tapestry.binding.ExpressionBinding.getObject(ExpressionBinding.ja
va:125)
        at
org.apache.tapestry.binding.AbstractBinding.getObject(AbstractBinding.java:8
4)
        at $ExternalLink_12.getParameters($ExternalLink_12.java)
        at
org.apache.tapestry.link.ExternalLink.getLink(ExternalLink.java:40)
        at
org.apache.tapestry.link.DefaultLinkRenderer.constructURL(DefaultLinkRendere
r.java:120)
        at
org.apache.tapestry.link.DefaultLinkRenderer.renderLink(DefaultLinkRenderer.
java:68)
        at
org.apache.tapestry.link.AbstractLinkComponent.renderComponent(AbstractLinkC
omponent.java:94)
        at
org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:725)


[..snip..]

Caused by: org.apache.hivemind.ApplicationRuntimeException: Unable to parse
OGNL expression 'model': model
        at
org.apache.tapestry.services.impl.ExpressionCacheImpl.parse(ExpressionCacheI
mpl.java:156)
        at
org.apache.tapestry.services.impl.ExpressionCacheImpl.getCompiledExpression(
ExpressionCacheImpl.java:115)
        at
$ExpressionCache_1189177e273.getCompiledExpression($ExpressionCache_1189177e
273.java)
        at
org.apache.tapestry.binding.ExpressionBinding.resolveExpression(ExpressionBi
nding.java:134)
        ... 89 more
Caused by: ognl.OgnlException: model [org.apache.tapestry.BindingException:
Unable to parse OGNL expression
'page.persistenceService.getInstance(gov.nasa.jpl.edrn.Participant.class)':
$HomePage_0.gov [context:/WEB-INF/Home.html, line 7]]
        at ognl.OgnlRuntime.getMethodValue(OgnlRuntime.java:1215)
        at
ognl.ObjectPropertyAccessor.getPossibleProperty(ObjectPropertyAccessor.java:
60)
        at
ognl.ObjectPropertyAccessor.getProperty(ObjectPropertyAccessor.java:144)

[..snip..]

As far as I can tell the TrailsPage component that all pages inherit from
(I'm guessing the Home.page does too) provides the persistenceService, so I
should be able to access it from ognl:, and as far as I can tell as well,
the model="" parameter of the EditLink expects a java.lang.Object, which I'm
guessing is the object to bring up an edit page for. The weirdest thing is,
if I change my EditLink call above to:

<a href="#" jwcid="@trails:EditLink" model="ognl:new
gov.nasa.jpl.edrn.Participant()">Add a New Participant</a>

The link renders on my Home.page, but when I click it, I get a null pointer
exception message when it tries to take me to the EditPage. So I guess that
Hibernate probably sets up some magic in the Participant object returned
from persistenceService.getInstance that my regular old new Participant()
call didn't do. So, I thought that calling it would fix the problem but it
didn't. Can anyone help me?

Thanks!

Cheers,
 Chris



______________________________________________
Chris Mattmann, Ph.D.
Chris.Mattmann@...
Cognizant Development Engineer
Early Detection Research Network Project
_________________________________________________
Jet Propulsion Laboratory            Pasadena, CA
Office: 171-266B                     Mailstop:  171-246
_______________________________________________________

Disclaimer:  The opinions presented within are my own and do not reflect
those of either NASA, JPL, or the California Institute of Technology.



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Help using EditLink component