Hi, it begins to work!

After I changed 'form' to 'this', the file compiled without problems.
          if ("2".equals((String)this.get("selectie"))) {
==>             Boolean bVolledig =
Boolean.valueOf((String)this.get("volledig"));
                boolean volleNaam = bVolledig.booleanValue();
                if (volleNaam) {
                        errors.add("Volledige naam", new
ActionError("error.naam.volledig"));
                } else {
                        errors.add("Beginletters", new
ActionError("error.naam.deel"));
                }
          }       
The DynaActionForm belongs to the following form:

<logic:equal name="zoekDynaForm" property="selectie" value="2">
  <bean:message key="zoekraak.data.geslachtsnaam" /><html:text size="12"
property="geslachtsnaam" />
  <bean:message key="zoekraak.data.volledig" /><html:checkbox
property="volledig" onclick="submit()" />
  ... skip...
  <html:submit property="submitknop"><bean:message
key="zoekraak.persoon.zoekknop" /></html:submit>&nbsp;
</logic:equal>

and the first time the form is displayed, it comes with the first error
(volledig=true)
After clicking the checkbox the form should come back with the second
message but instead jsp raises the following exeception:
java.lang.ClassCastException (on the indicated line)

It probably has to do something with prepopulating the form but now at least
I know in which direction I should search for the solution. (And by
searching, I learn most =:0)

Thanks,
Ben

++++++++

Hi!

Try this:
        Boolean bVolledig = Boolean.valueOf((String)form.get("volledig"));
        boolean volledig = bVolledig.booleanValue();

Should work

Pedro Salgado

> Hi,
> 
> I have defined a boolean property in a DynaActionForm ("volledig" which
> means complete).
> 
> The value should be checked in the validate()-method.
> It is easy to retrieve String-properties from the hash-map but the
compiler
> does not accept the following construct:
> if ((boolean)this.get("volledig"))
> complaining that it :Cannot cast from Object to boolean.
> 
...
  
>  if ("2".equals((String)this.get("selectie"))) {
> ==>          if ((boolean)this.get("volledig")) {
> errors.add("Volledige naam", new
> ActionError("error.naam.volledig"));
> } else {
> errors.add("Beginletters", new
> ActionError("error.naam.deel"));
> }
>  }
>  return (errors);
> }
> }




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to