You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Montier Patrick <pa...@easance.com> on 2002/06/07 18:44:33 UTC

Form-validator error in AbstractValidatorAction.java

Hi,

I feel very unlucky with cocoon. I installed the 2.0.1 release : error in
nullable tag. Someone told me to install a newer one.

SO i installed the 2.0.2 and now the form validator show an exception... i'm
so dispointed..

the AbstractValidatorAction.java, getdefaut function seem to crash when
verifing the default value.
I try to put or remove default value, it's the same result :

I need some help.

Thank you

Patrick

PARAM: 'login' VALUES: '[pmontier]'
PARAM: 'password' VALUES: '[xxxx]'
PARAM: 'isCompany' VALUES: '[f]'

sirtemap.log
[1]/AbstractComplementaryConfigurableAction: Using cached configuration for
context://bethe1/descriptors/params.xml
[1]/FormValidatorAction: Validating parameters as specified via 'validate'
parameter
[1]/AbstractValidatorAction: Validating parameter: login
[1]/FormValidatorAction: exception:
java.lang.NullPointerException
        at
org.apache.cocoon.acting.AbstractValidatorAction.getDefault(AbstractValidato
rAction.java:576)
        at
org.apache.cocoon.acting.AbstractValidatorAction.validateString(AbstractVali
datorAction.java:222)
        at
org.apache.cocoon.acting.AbstractValidatorAction.validateParameter(AbstractV
alidatorAction.java:202)
        at
org.apache.cocoon.acting.FormValidatorAction.act(FormValidatorAction.java:16
9)

sitemap.xmap :
      <map:match pattern="asp*/*/do-login">
        <!-- first validate whether submitted values are ok -->
        <map:act type="form-validator">
          <map:parameter name="descriptor"
value="context://bethe1/descriptors/params.xml"/>
          <map:parameter name="validate" value="login,password"/>
          <!-- now try to log in -->
          <map:act type="db-authenticator">
            <map:parameter name="descriptor"
value="context://bethe1/descriptors/auth.xml"/>
            <!-- now go to protected area -->
            <map:redirect-to uri="login_ok.htm"/>
          </map:act>
        </map:act>
        <!-- something was wrong, try it again -->
        <map:redirect-to uri="login_nok.htm"/>
      </map:match>

params.xml :

<!--
This file is used for description of request and session parameters.
parameters that are nullable and are found being null are replaced with
their
default values, non-nullable parameters can make the validation process
fail.
-->
<parameters-descriptor>
<parameter name="login" type="string" nullable="no"/>
<parameter name="id_rus" type="long" nullable="no"/>
<parameter name="password" type="string" nullable="no"/>
</parameters-descriptor>

the FUNCTION in AbstractValidatorAction.java :
 /**
     * Returns the default value from given configuration or constraints.
     * Value present in constraints takes precedence, null is returned when
no
     * default attribute is present in eiher of them.
     */
    private String getDefault(Configuration conf, Configuration cons) {
        String dflt = null;
        try {
            dflt = cons.getAttribute("default");
        } catch (ConfigurationException e) {
            dflt = conf.getAttribute("default", "");
        }
        if ("".equals(dflt.trim())) {
            dflt = null;
        }
        return dflt;
    }


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


RE: Form-validator error in AbstractValidatorAction.java

Posted by Vadim Gritsenko <va...@verizon.net>.
> From: Montier Patrick [mailto:patrick.montier@easance.com]
> 
> 
> Hi,
> 
> I feel very unlucky with cocoon. I installed the 2.0.1 release : error
in
> nullable tag. Someone told me to install a newer one.
> 
> SO i installed the 2.0.2 and now the form validator show an
exception... i'm
> so dispointed..

Now you should install 2.0.3 :)

Seriously.

Vadim


> 
> the AbstractValidatorAction.java, getdefaut function seem to crash
when
> verifing the default value.
> I try to put or remove default value, it's the same result :
> 
> I need some help.
> 
> Thank you
> 
> Patrick
> 
> PARAM: 'login' VALUES: '[pmontier]'
> PARAM: 'password' VALUES: '[xxxx]'
> PARAM: 'isCompany' VALUES: '[f]'
> 
> sirtemap.log
> [1]/AbstractComplementaryConfigurableAction: Using cached
configuration for
> context://bethe1/descriptors/params.xml
> [1]/FormValidatorAction: Validating parameters as specified via
'validate'
> parameter
> [1]/AbstractValidatorAction: Validating parameter: login
> [1]/FormValidatorAction: exception:
> java.lang.NullPointerException
>         at
>
org.apache.cocoon.acting.AbstractValidatorAction.getDefault(AbstractVali
dato
> rAction.java:576)
>         at
>
org.apache.cocoon.acting.AbstractValidatorAction.validateString(Abstract
Vali
> datorAction.java:222)
>         at
>
org.apache.cocoon.acting.AbstractValidatorAction.validateParameter(Abstr
actV
> alidatorAction.java:202)
>         at
>
org.apache.cocoon.acting.FormValidatorAction.act(FormValidatorAction.jav
a:16
> 9)
> 
> sitemap.xmap :
>       <map:match pattern="asp*/*/do-login">
>         <!-- first validate whether submitted values are ok -->
>         <map:act type="form-validator">
>           <map:parameter name="descriptor"
> value="context://bethe1/descriptors/params.xml"/>
>           <map:parameter name="validate" value="login,password"/>
>           <!-- now try to log in -->
>           <map:act type="db-authenticator">
>             <map:parameter name="descriptor"
> value="context://bethe1/descriptors/auth.xml"/>
>             <!-- now go to protected area -->
>             <map:redirect-to uri="login_ok.htm"/>
>           </map:act>
>         </map:act>
>         <!-- something was wrong, try it again -->
>         <map:redirect-to uri="login_nok.htm"/>
>       </map:match>
> 
> params.xml :
> 
> <!--
> This file is used for description of request and session parameters.
> parameters that are nullable and are found being null are replaced
with
> their
> default values, non-nullable parameters can make the validation
process
> fail.
> -->
> <parameters-descriptor>
> <parameter name="login" type="string" nullable="no"/>
> <parameter name="id_rus" type="long" nullable="no"/>
> <parameter name="password" type="string" nullable="no"/>
> </parameters-descriptor>
> 
> the FUNCTION in AbstractValidatorAction.java :
>  /**
>      * Returns the default value from given configuration or
constraints.
>      * Value present in constraints takes precedence, null is returned
when
> no
>      * default attribute is present in eiher of them.
>      */
>     private String getDefault(Configuration conf, Configuration cons)
{
>         String dflt = null;
>         try {
>             dflt = cons.getAttribute("default");
>         } catch (ConfigurationException e) {
>             dflt = conf.getAttribute("default", "");
>         }
>         if ("".equals(dflt.trim())) {
>             dflt = null;
>         }
>         return dflt;
>     }
> 


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>