[opencms-dev] Xmlcontent problem when editing contents. Validation rules aren't triggered at the right time

Javier . mailinglists.javi at gmail.com
Thu Nov 16 21:18:25 CET 2006


I've found a problem related to xmlcontents. It's about the Editor and the
time when validation rules are triggered.

It appears in Opencms 6.2.1 and 6.2.2.

These are the steps to reproduce it:

Firstly, I've defined a new content (Pages).  It's a multilingual content
(the language is selected from a Combo). Each Page has two elements, a Title
and a Paragraph.
The Title must not be empty (required field), so I've created a validation
rule that checks that constraint (regex="!^\s*$" ).

The schema definition is as follows:

###########################################

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">

    <xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd"/>

    <xsd:element name="Pages" type="OpenCmsPages"/>
    <xsd:complexType name="OpenCmsPages">
        <xsd:sequence>
            <xsd:element name="Page" type="OpenCmsPage" minOccurs="0"
maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="OpenCmsPage">
        <xsd:sequence>
            <xsd:element name="Title" type="OpenCmsString"  />
            <xsd:element name="Paragraph" type="OpenCmsString"  />
        </xsd:sequence>
        <xsd:attribute name="language" type="OpenCmsLocale" use="optional"/>
    </xsd:complexType>

    <xsd:annotation>
        <xsd:appinfo>
            <validationrules>
                <rule element="Title" regex="!^\s*$" message="${
key.editor.errormessage.Page.Title.required|${validation.path}}" />
            <layouts>
                <layout element="Paragraph" widget="HtmlWidget" />
            </layouts>
        </xsd:appinfo>
    </xsd:annotation>
</xsd:schema>

###########################################

Secondly,  I  configured a new resource type (in opencms-vfs.xml) and a "New
File" menĂº entry (opencms-workplace.xml) for that content.

All works fine. I can create a new Page, using the "New" button.

The problem appears when editing the content (from the visual xmlcontent
editor, selecting "Edit", not selecting "Edit sourcecode").

As I stated before, it's a multilingual content. When you edit the content,
a language is just selected (the default one). The validation rules aren't
triggered until you press the save button. The edition for the default
language works fine. The rules are checked only when you press the button.

But the problem comes when you select another language (from the combo).

At the time you select another language, the validation rules are triggered.
The fields are empty the first time you edit a content in a language. As the
fields for the language we've selected are empty, the validation engine
throws an error (the Title field mus not be empty).

The worst thing is that you're returned automatically to the previous
language form, so you can't edit the content in another language.

I think it is a bug. There was a similar bug previously, which was fixed:

###########################################################

"We are running on 6.0.2. In one of our xsd files, we put in a validation
rule to ensure that this field is populated (a required field). So the
validation rule was:



<validationrules>

<rule element="Title" regex="!^\s*$" type="warning"
message="Title field should not be left empty" />

</validationrules>



The problem is that this error shows up when we create a new piece of
structured content. Why isn't the validation rule only called on save or
did we do something wrong? "

" We actually sent this into Alkacon and they patched it in the 6.2 branch.
So yes it was addressed, but no it doesn't work in any of the code probably
more recent than like 10 days ago.

Joel "

###########################################################


I send this problem to the mailing list first, as advised.
If it's really a bug, please report it.

Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20061116/fd23dab4/attachment.htm>


More information about the opencms-dev mailing list