cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Reinhard Poetz (JIRA)" <j...@apache.org>
Subject [jira] Updated: (COCOON-1271) Custom Binding
Date Tue, 25 Oct 2005 06:35:59 GMT
     [ http://issues.apache.org/jira/browse/COCOON-1271?page=all ]

Reinhard Poetz updated COCOON-1271:
-----------------------------------

    Bugzilla Id:   (was: 31303)
      Component: - Cocoon Forms
                     (was: Blocks: (Undefined))
    Description: 
In the forms binding frame work you can define a cutom binding class by 
extending org.apache.cocoon.forms.AbstractCustomBinding and implementing 
methods foLoad() and doSave().

This is nice but I think there is a little design issue in class 
org.apache.cocoon.forms.CustomJXPathBinding. Look at following case:

* Take a JavaBean with a other bean as property named test
* Make a custom binder that loads an sets this property from the JavaBean with 
implementation:

doLoad(Widget frmModel, JXPathContext jxpc) {
    jxpc.setLenient(true);
    Object aValue = jxpc.getValue(".");
    jxpc.setLenient(false);
    if(aValue != null)
        frmModel.setValue(jxpc.getValue(".").toString());
}

doSave(Widget frmModel, JXPathContext jxpc) {
    jxpc.setValue(".", LookupUtil.lookupValue(frmModel.getValue()));
}

and in binding xml:

<fb:custom id="test" path="test" class="ch.wellernet.MyCustomBinding"/>

This runs very well if test property isn't null. But is it is null an execption 
is throw before the code in MyCustomBinding is executed (in 
CustomJXPathBinding, line 68 on load, 83 on save) because relative context 
cannot be cerate for a null value!

So I changed the AbstractCustomBinding as like this:

protected abstract void doLoad(Widget frmModel, JXPathContext context, String 
path) throws BindingException;

protected abstract void doSave(Widget frmModel, JXPathContext context, String 
path) throws BindingException;

So I class the doXXX methods with parent context and the selection path, so it 
is possible to handle the null case in custom implementation.

Hope this will help some one in cocoon team (and thanks a lot for your good 
work).

  was:
In the forms binding frame work you can define a cutom binding class by 
extending org.apache.cocoon.forms.AbstractCustomBinding and implementing 
methods foLoad() and doSave().

This is nice but I think there is a little design issue in class 
org.apache.cocoon.forms.CustomJXPathBinding. Look at following case:

* Take a JavaBean with a other bean as property named test
* Make a custom binder that loads an sets this property from the JavaBean with 
implementation:

doLoad(Widget frmModel, JXPathContext jxpc) {
    jxpc.setLenient(true);
    Object aValue = jxpc.getValue(".");
    jxpc.setLenient(false);
    if(aValue != null)
        frmModel.setValue(jxpc.getValue(".").toString());
}

doSave(Widget frmModel, JXPathContext jxpc) {
    jxpc.setValue(".", LookupUtil.lookupValue(frmModel.getValue()));
}

and in binding xml:

<fb:custom id="test" path="test" class="ch.wellernet.MyCustomBinding"/>

This runs very well if test property isn't null. But is it is null an execption 
is throw before the code in MyCustomBinding is executed (in 
CustomJXPathBinding, line 68 on load, 83 on save) because relative context 
cannot be cerate for a null value!

So I changed the AbstractCustomBinding as like this:

protected abstract void doLoad(Widget frmModel, JXPathContext context, String 
path) throws BindingException;

protected abstract void doSave(Widget frmModel, JXPathContext context, String 
path) throws BindingException;

So I class the doXXX methods with parent context and the selection path, so it 
is possible to handle the null case in custom implementation.

Hope this will help some one in cocoon team (and thanks a lot for your good 
work).


> Custom Binding
> --------------
>
>          Key: COCOON-1271
>          URL: http://issues.apache.org/jira/browse/COCOON-1271
>      Project: Cocoon
>         Type: Improvement
>   Components: - Cocoon Forms
>     Versions: 2.1.5
>  Environment: Operating System: All
> Platform: All
>     Reporter: Lucien Weller
>     Assignee: Cocoon Developers Team
>     Priority: Minor

>
> In the forms binding frame work you can define a cutom binding class by 
> extending org.apache.cocoon.forms.AbstractCustomBinding and implementing 
> methods foLoad() and doSave().
> This is nice but I think there is a little design issue in class 
> org.apache.cocoon.forms.CustomJXPathBinding. Look at following case:
> * Take a JavaBean with a other bean as property named test
> * Make a custom binder that loads an sets this property from the JavaBean with 
> implementation:
> doLoad(Widget frmModel, JXPathContext jxpc) {
>     jxpc.setLenient(true);
>     Object aValue = jxpc.getValue(".");
>     jxpc.setLenient(false);
>     if(aValue != null)
>         frmModel.setValue(jxpc.getValue(".").toString());
> }
> doSave(Widget frmModel, JXPathContext jxpc) {
>     jxpc.setValue(".", LookupUtil.lookupValue(frmModel.getValue()));
> }
> and in binding xml:
> <fb:custom id="test" path="test" class="ch.wellernet.MyCustomBinding"/>
> This runs very well if test property isn't null. But is it is null an execption 
> is throw before the code in MyCustomBinding is executed (in 
> CustomJXPathBinding, line 68 on load, 83 on save) because relative context 
> cannot be cerate for a null value!
> So I changed the AbstractCustomBinding as like this:
> protected abstract void doLoad(Widget frmModel, JXPathContext context, String 
> path) throws BindingException;
> protected abstract void doSave(Widget frmModel, JXPathContext context, String 
> path) throws BindingException;
> So I class the doXXX methods with parent context and the selection path, so it 
> is possible to handle the null case in custom implementation.
> Hope this will help some one in cocoon team (and thanks a lot for your good 
> work).

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message