You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by bu...@apache.org on 2005/09/20 12:39:58 UTC

DO NOT REPLY [Bug 36727] New: - Enum datatype does not work with multivalue field

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=36727>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=36727

           Summary: Enum datatype does not work with multivalue field
           Product: Cocoon 2
           Version: Current SVN 2.1
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: CocoonForms
        AssignedTo: dev@cocoon.apache.org
        ReportedBy: ugo@apache.org


When using an Enum datatype with a multivalue field:

    <fd:multivaluefield id="features">
      <fd:label><i18n:text>label.features</i18n:text></fd:label>
      <fd:datatype base="enum">
        <fd:convertor type="enum">
          <fd:enum>com.pnetx.pulse.domain.enums.RoomFeature</fd:enum> 
        </fd:convertor>
      </fd:datatype>
      <fd:selection-list type="enum"
class="com.pnetx.pulse.domain.enums.RoomFeature" nullable="false"/>
    </fd:multivaluefield>

a NullPointerException is generated when displaying the form if it is bound to
an object having not-null values for the field in question. Here is the relevant
portion of the stacktrace:

Caused by: java.lang.NullPointerException
	at
org.apache.cocoon.forms.formmodel.MultiValueField.generateItemSaxFragment(MultiValueField.java:150)
	at
org.apache.cocoon.forms.formmodel.AbstractWidget.generateSaxFragment(AbstractWidget.java:487)
	at
org.apache.cocoon.forms.generation.JXMacrosHelper.generateWidget(JXMacrosHelper.java:279)

The null here is the value returned from
definition.getDatatype().getPlainConvertor(). The problem is that an
EnumConvertor requires a class name to work and this can be configured only in
the form definition file, whereas the plain convertor is configured at startup
time (AbstractDatatypeBuilder.configure) and thus cannot know the name of the
class. Indeed, the EnumConvertorBuilder does:

   public Convertor build(Element configElement) throws Exception {
        if (configElement == null) {
            return null;
        }

Now, since there is no difference between a normal EnumConvertor and a "plain"
one, it probably makes sense to use the former when the latter is not available.
I have a fix for this that I will attach to this bug report, but I would like
someone more familiar with CForms than me to review it before committing.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.