You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Howard Lewis Ship <hl...@gmail.com> on 2007/03/06 20:05:56 UTC

[T5] ?. operator for null-safe graph traversal

customer?.address?.street

I've borrowed some syntax from Groovy to handle this case; the ?.
operator returns null if the LHS is null, otherwise is traverses into
the property on the RHS.

On 3/6/07, Angelo Luis <an...@gmail.com> wrote:
> No no no...
>
> How can have a null handler now???
>
> If a have a customer -> address -> street in a text component, for example "
> custumer.address.street" and i dont instanciate a address, a
> NullPointerException is throw. With a ognl null handler, if the address is
> null he creates one , like Webwork... i dont need to instanciate all object
> graph to use in a page...
>
> i will have this same problem in t5?
>
> On 3/5/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> >
> > Two problems here:
> >
> > 1) Not well formed XML.  That "<" inside the test attribute isn't
> > allow.  Use &lt;
> > 2) OGNL isn't supported in T5.
> >
> > For anything more complicated than a property access, you do the work
> > in Java code as a synthetic property.
> >
> > On 3/5/07, Davor Hrg <hr...@gmail.com> wrote:
> > > Hi,
> > > maybe this was reported and solved but here it goes ...
> > >
> > > I've tried the tapestry tutorial and it was very nice and easy.
> > > I've made few mistakes but error reporting is great so it was fixed
> > quickly.
> > >
> > > the problem occured when I tried to add some of the proposed changes to
> > the
> > > app..
> > >
> > > just to test the expressions I added:
> > >         <t:comp type="If" test="ognl:index<5">
> > >
> > > but I get the error
> > > Failure parsing template context:WEB-INF/Guess.html: The value of
> > attribute
> > > "test" associated with an element type "t:comp" must not contain the '<'
> > > character.
> > >
> > > Am I doing it wrong, or it's just a bug to be fixed later....
> > >
> > > Davor Hrg
> > >
> >
> >
> > --
> > Howard M. Lewis Ship
> > TWD Consulting, Inc.
> > Independent J2EE / Open-Source Java Consultant
> > Creator and PMC Chair, Apache Tapestry
> > Creator, Apache HiveMind
> >
> > Professional Tapestry training, mentoring, support
> > and project work.  http://howardlewisship.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] ?. operator for null-safe graph traversal

Posted by Jesse Kuhnert <jk...@gmail.com>.
Yeah...Thinking about it more now I realize that you don't really have
a choice. I'm still wondering how much mileage I'm liable to get out
of all of these OGNL changes if there is a better alternative..(ie if
groovy works just as well for property set/get operations ? ...)

I may send out an email to a few people to explore around first. There
are so many cool things to play with I don't want to waste my time if
there is an obvious alternative. (like maybe T5 itself, though I'm
even more wary of that right now - mostly because I think I'd be
getting in the way / distracting when some portions are still
forming...too many cooks can destroy a meal / er something... ;) )

On 3/6/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> It is definately a twisty path, before long I'll have reproduced all of OGNL.
>
> It might be fun to support "low..high" syntax for properties rather
> than constants, but that's getting to be as far as I want to take it.
> Do the heavy lifting in Java (or Groovy) code.
>
> On 3/6/07, Jesse Kuhnert <jk...@gmail.com> wrote:
> > Nice. I like that and the "0..." that you've added. Why can't we
> > replicate you for work on OGNL ? =p
> >
> > On 3/6/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> > > customer?.address?.street
> > >
> > > I've borrowed some syntax from Groovy to handle this case; the ?.
> > > operator returns null if the LHS is null, otherwise is traverses into
> > > the property on the RHS.
> > >
> > > On 3/6/07, Angelo Luis <an...@gmail.com> wrote:
> > > > No no no...
> > > >
> > > > How can have a null handler now???
> > > >
> > > > If a have a customer -> address -> street in a text component, for example "
> > > > custumer.address.street" and i dont instanciate a address, a
> > > > NullPointerException is throw. With a ognl null handler, if the address is
> > > > null he creates one , like Webwork... i dont need to instanciate all object
> > > > graph to use in a page...
> > > >
> > > > i will have this same problem in t5?
> > > >
> > > > On 3/5/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> > > > >
> > > > > Two problems here:
> > > > >
> > > > > 1) Not well formed XML.  That "<" inside the test attribute isn't
> > > > > allow.  Use &lt;
> > > > > 2) OGNL isn't supported in T5.
> > > > >
> > > > > For anything more complicated than a property access, you do the work
> > > > > in Java code as a synthetic property.
> > > > >
> > > > > On 3/5/07, Davor Hrg <hr...@gmail.com> wrote:
> > > > > > Hi,
> > > > > > maybe this was reported and solved but here it goes ...
> > > > > >
> > > > > > I've tried the tapestry tutorial and it was very nice and easy.
> > > > > > I've made few mistakes but error reporting is great so it was fixed
> > > > > quickly.
> > > > > >
> > > > > > the problem occured when I tried to add some of the proposed changes to
> > > > > the
> > > > > > app..
> > > > > >
> > > > > > just to test the expressions I added:
> > > > > >         <t:comp type="If" test="ognl:index<5">
> > > > > >
> > > > > > but I get the error
> > > > > > Failure parsing template context:WEB-INF/Guess.html: The value of
> > > > > attribute
> > > > > > "test" associated with an element type "t:comp" must not contain the '<'
> > > > > > character.
> > > > > >
> > > > > > Am I doing it wrong, or it's just a bug to be fixed later....
> > > > > >
> > > > > > Davor Hrg
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Howard M. Lewis Ship
> > > > > TWD Consulting, Inc.
> > > > > Independent J2EE / Open-Source Java Consultant
> > > > > Creator and PMC Chair, Apache Tapestry
> > > > > Creator, Apache HiveMind
> > > > >
> > > > > Professional Tapestry training, mentoring, support
> > > > > and project work.  http://howardlewisship.com
> > > > >
> > > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > > >
> > > > >
> > > >
> > >
> > >
> > > --
> > > Howard M. Lewis Ship
> > > TWD Consulting, Inc.
> > > Independent J2EE / Open-Source Java Consultant
> > > Creator and PMC Chair, Apache Tapestry
> > > Creator, Apache HiveMind
> > >
> > > Professional Tapestry training, mentoring, support
> > > and project work.  http://howardlewisship.com
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
> > --
> > Jesse Kuhnert
> > Tapestry/Dojo team member/developer
> >
> > Open source based consulting work centered around
> > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> Howard M. Lewis Ship
> TWD Consulting, Inc.
> Independent J2EE / Open-Source Java Consultant
> Creator and PMC Chair, Apache Tapestry
> Creator, Apache HiveMind
>
> Professional Tapestry training, mentoring, support
> and project work.  http://howardlewisship.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] ?. operator for null-safe graph traversal

Posted by Howard Lewis Ship <hl...@gmail.com>.
It is definately a twisty path, before long I'll have reproduced all of OGNL.

It might be fun to support "low..high" syntax for properties rather
than constants, but that's getting to be as far as I want to take it.
Do the heavy lifting in Java (or Groovy) code.

On 3/6/07, Jesse Kuhnert <jk...@gmail.com> wrote:
> Nice. I like that and the "0..." that you've added. Why can't we
> replicate you for work on OGNL ? =p
>
> On 3/6/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> > customer?.address?.street
> >
> > I've borrowed some syntax from Groovy to handle this case; the ?.
> > operator returns null if the LHS is null, otherwise is traverses into
> > the property on the RHS.
> >
> > On 3/6/07, Angelo Luis <an...@gmail.com> wrote:
> > > No no no...
> > >
> > > How can have a null handler now???
> > >
> > > If a have a customer -> address -> street in a text component, for example "
> > > custumer.address.street" and i dont instanciate a address, a
> > > NullPointerException is throw. With a ognl null handler, if the address is
> > > null he creates one , like Webwork... i dont need to instanciate all object
> > > graph to use in a page...
> > >
> > > i will have this same problem in t5?
> > >
> > > On 3/5/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> > > >
> > > > Two problems here:
> > > >
> > > > 1) Not well formed XML.  That "<" inside the test attribute isn't
> > > > allow.  Use &lt;
> > > > 2) OGNL isn't supported in T5.
> > > >
> > > > For anything more complicated than a property access, you do the work
> > > > in Java code as a synthetic property.
> > > >
> > > > On 3/5/07, Davor Hrg <hr...@gmail.com> wrote:
> > > > > Hi,
> > > > > maybe this was reported and solved but here it goes ...
> > > > >
> > > > > I've tried the tapestry tutorial and it was very nice and easy.
> > > > > I've made few mistakes but error reporting is great so it was fixed
> > > > quickly.
> > > > >
> > > > > the problem occured when I tried to add some of the proposed changes to
> > > > the
> > > > > app..
> > > > >
> > > > > just to test the expressions I added:
> > > > >         <t:comp type="If" test="ognl:index<5">
> > > > >
> > > > > but I get the error
> > > > > Failure parsing template context:WEB-INF/Guess.html: The value of
> > > > attribute
> > > > > "test" associated with an element type "t:comp" must not contain the '<'
> > > > > character.
> > > > >
> > > > > Am I doing it wrong, or it's just a bug to be fixed later....
> > > > >
> > > > > Davor Hrg
> > > > >
> > > >
> > > >
> > > > --
> > > > Howard M. Lewis Ship
> > > > TWD Consulting, Inc.
> > > > Independent J2EE / Open-Source Java Consultant
> > > > Creator and PMC Chair, Apache Tapestry
> > > > Creator, Apache HiveMind
> > > >
> > > > Professional Tapestry training, mentoring, support
> > > > and project work.  http://howardlewisship.com
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > >
> > > >
> > >
> >
> >
> > --
> > Howard M. Lewis Ship
> > TWD Consulting, Inc.
> > Independent J2EE / Open-Source Java Consultant
> > Creator and PMC Chair, Apache Tapestry
> > Creator, Apache HiveMind
> >
> > Professional Tapestry training, mentoring, support
> > and project work.  http://howardlewisship.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5] ?. operator for null-safe graph traversal

Posted by Jesse Kuhnert <jk...@gmail.com>.
Nice. I like that and the "0..." that you've added. Why can't we
replicate you for work on OGNL ? =p

On 3/6/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> customer?.address?.street
>
> I've borrowed some syntax from Groovy to handle this case; the ?.
> operator returns null if the LHS is null, otherwise is traverses into
> the property on the RHS.
>
> On 3/6/07, Angelo Luis <an...@gmail.com> wrote:
> > No no no...
> >
> > How can have a null handler now???
> >
> > If a have a customer -> address -> street in a text component, for example "
> > custumer.address.street" and i dont instanciate a address, a
> > NullPointerException is throw. With a ognl null handler, if the address is
> > null he creates one , like Webwork... i dont need to instanciate all object
> > graph to use in a page...
> >
> > i will have this same problem in t5?
> >
> > On 3/5/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> > >
> > > Two problems here:
> > >
> > > 1) Not well formed XML.  That "<" inside the test attribute isn't
> > > allow.  Use &lt;
> > > 2) OGNL isn't supported in T5.
> > >
> > > For anything more complicated than a property access, you do the work
> > > in Java code as a synthetic property.
> > >
> > > On 3/5/07, Davor Hrg <hr...@gmail.com> wrote:
> > > > Hi,
> > > > maybe this was reported and solved but here it goes ...
> > > >
> > > > I've tried the tapestry tutorial and it was very nice and easy.
> > > > I've made few mistakes but error reporting is great so it was fixed
> > > quickly.
> > > >
> > > > the problem occured when I tried to add some of the proposed changes to
> > > the
> > > > app..
> > > >
> > > > just to test the expressions I added:
> > > >         <t:comp type="If" test="ognl:index<5">
> > > >
> > > > but I get the error
> > > > Failure parsing template context:WEB-INF/Guess.html: The value of
> > > attribute
> > > > "test" associated with an element type "t:comp" must not contain the '<'
> > > > character.
> > > >
> > > > Am I doing it wrong, or it's just a bug to be fixed later....
> > > >
> > > > Davor Hrg
> > > >
> > >
> > >
> > > --
> > > Howard M. Lewis Ship
> > > TWD Consulting, Inc.
> > > Independent J2EE / Open-Source Java Consultant
> > > Creator and PMC Chair, Apache Tapestry
> > > Creator, Apache HiveMind
> > >
> > > Professional Tapestry training, mentoring, support
> > > and project work.  http://howardlewisship.com
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
>
>
> --
> Howard M. Lewis Ship
> TWD Consulting, Inc.
> Independent J2EE / Open-Source Java Consultant
> Creator and PMC Chair, Apache Tapestry
> Creator, Apache HiveMind
>
> Professional Tapestry training, mentoring, support
> and project work.  http://howardlewisship.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org