cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Joseph <pjoseph...@yahoo.com>
Subject multi-value widget question
Date Wed, 29 Sep 2004 13:30:43 GMT
Hi,

I am having a problem with a multi-value widget.

The problem is this:

I am using a multi-value widget called Roles.  It will
return a value of an array of integers.

So, my widget is defined as follows:
    <fd:multivaluefield  id="roles">
      <fd:label>Roles</fd:label>
      <fd:datatype base="integer"/>
      <fd:selection-list type="flow-jxpath"
list-path="roleList" value-path="value"
label-path="label"/>
    </fd:multivaluefield>

It populates correctly.

The problem is when I get user data and try to save it
to the database.

I get the infamous error:

org.apache.commons.jxpath.JXPathException: Exception
trying to create xpath roles[1]; Cannot access
property:
org.apache.cocoon.ojb.samples.bean.DictUser.roles;
java.lang.reflect.InvocationTargetException


My binding file is:

    <fb:multi-value id="roles" parent-path="."
row-path="roles"/>


I am trying to persist the data to the database in a
column of varchar(100).

I am able to retrieve the data that I manually enter
into the database and select the correct labels in the
multi-value selector.

It is only when I try to save it, that I get this
error.

The get and set methods I am now using are as follows
(the get works, but not the set):

private String roles;

public Integer[] getRoles() {
    Vector v = new Vector();
        StringTokenizer strTok = new
StringTokenizer(roles, ",");
        int i = 0;
        while (strTok.hasMoreTokens()){
            String val = strTok.nextToken();
            Integer intVal = new Integer(val);
            v.add(intVal);
            i++;
        }
        Integer[] intArray = (Integer[]) v.toArray(new
Integer[1]);
        return intArray;
}

public void setRoles(Collection arraylistroles) {
    Iterator it = arraylistroles.iterator();
    if(it.hasNext()) roles = (String)it.next();
    while (it.hasNext()) {
	roles = roles + "," + (String)it.next();
	}
     this.roles = roles;
}

Any help will be appreciated!

thx
Paul


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


Mime
View raw message