cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Per-Olof Noren <pe...@alma.nu>
Subject Re: [cforms] add lenient setting to context binding
Date Thu, 18 Dec 2003 13:49:58 GMT



Hi all,

Just by adding setLenient won't take away all Exceptions from jxpath.

We're using xsp to create our views to data obtained by OJB's
PersistenceBroker API.

To do this, we had to patch the jxpath library for the setLenient method
to really be lenient for all xpaths used in the view.
We also patched jpath.xsl for the xsp to use setLenient on the root
context.

I haven't looked at the cocoon cforms code, but I figured I had to chip
in my two cents of experience :-)
 
A little UseCase

The database:
----------------------------

+------+
| Item |
+------+
  | 1
  |
  | *
+-----------+
| Property  |
+-----------+
  | *
  |
  | 1
+--------------+
| PropertyType |
+--------------+


The classes:
----------------------------

public class Item {
    int id;
    Collection properties;
    public Collection getProperties();
}

public class Property {
    PropertyType type;
    Object value;
    public PropertyType getPropertyType();
}

public class PropertyType {
    int id;
    String name;
    String description;
    // getters and setters
}


The Flow:
-------------------------------
DbOperations dbOp= new DbOperations();
Item theItem = dbOp.getItem(1001);
cocoon.sendPageAndWait("item_detail.view", {"item": theItem});


The View (xsp):
--------------------------------
<view>
 <jpath:value select="item/id">
 <jpath:value select="item/properties[0]/value">
 <jpath:value select="item/properties[0]/propertyType/name">
</view>

Only the first xpath is truly lenient if the item does not have any
properties.

We had a diskussion with one of the jxspath guys, proposing changes
to jxpath to allow all of the above xpaths without surrounding every
<jpath:value-of> with <jpath:if>.

One could say it's not best practice not to check with jxpath:if first,
but I like the idea of a behaviour that is similar to the xpath used in
the stylesheets in other parts of cocoon.

I'd like it if we could take up the discussion with the jxpath team
on this matter. To me lenient mode should be free of exceptions.

I haven't figured out a way to implement configurability of this setting
in xsp. Given an interest and some info pointers, I can help to
implement this in xsp:s as well.



What do you think?

Per-Olof Norén
Curalia AB



On Thu, 2003-12-18 at 09:20, Marc Portier wrote:
> Sylvain wrote:
> 
> > Timothy Larson wrote:
> > 
> >> --- Marc Portier <mpo@outerthought.org> wrote:
> >> 
> >> 
> >> > Timothy Larson wrote:
> >> > 
> >> > 
> >> > > What do you think of adding an optional "lenient" attribute to the
context \
> >> > > binding? 
> >> > > 
> > 
> > +1. I would even set it to true by default.
> > 
> 
> the top level is set to have a lenient = true
> for the bindings deeper down in the tree there is the described 
> three-state-logic:
> 
> unset --> no change
> true/false --> set to specified leniency
> 
> >> > having just done the @direction refactoring I would even suggest to put
this also \
> >> > on the top level (JXPathBindingBase) so all binding elements get this feature:

> >> > 
> >> 
> >> Making it general sounds good.
> 
> I refactored the approach to introduce some CommonAttributes, it should 
> be easier now to add more of those. (should have done that directly with 
> the @direction stuff, but hey)
> 
> >> Do I pick up a hint that you prefer on/off instead of true/false?
> >> Which should we pick for the lenient attribute value:
> >> on/off, true/false, or yes/no?
> >> The name "lenient" came from the JXPathContext API.  Is that the best name,
or can \
> >> we think of a clearer name for the attribute? 
> >> 
> > 
> > true/false seems good to me...
> > 
> 
> and the easiest...
> I wasn't really hinting
> 
> > Sylvain
> 
> I just checked this in, comments welcome.
> -marc=
> (a bit awkward connected from my working spot here: I do have ssh access 
> to cvs.apache.org but no IMAP connection to the personal mailbox, so 
> sorry for late replies (reading through archives) and messing up your 
> mail-client-threading)


Mime
View raw message