[ 
https://issues.apache.org/jira/browse/WICKET-839?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12519362
 ] 

Igor Vaynberg commented on WICKET-839:
--------------------------------------

i dont like your fix because it really doesnt make sense - in fact my hack made 
more sense, let me try to explain in more detail:

formcomponentpanel does not aggregate RAW input from its children - it simply 
makes no sense - what it aggregates is the CONVERTED/processed input of its 
children - and it combines that into one object.

the problem is that the naming is bad. in fact - we have two required checks 
right now. one is for the raw input and happens before type conversion, the 
other one is for the converted input.  for the converted input checkrequired() 
is never called.  this is needed because it is possible that some entered input 
might get converted into null by the supplied converter.

i think what you are doing is pigeonholing something into that check that 
shouldnt be there - and i think part of that is because names are bad as they 
are right now - and that is partly because we try to preserve the api as much 
as possible. what my hack did, and why it makes more sense to me, is 
effectively disable that check for formcomponentpanel.

so here is my take on what the names should be and how it should work:

getinputasarray() -> getrawinput() whatever is getrawinput() right now should 
be merged into getinputasarray()
this change makes sense because that is what inputasarray() gets - the raw 
input submitted for that component.

validaterequired() -> validaterequiredrawinput()
checkrequired() -> either merged into validaterequiredinput() or 
->checkrequiredrawinput()

see, given these names it would totally make sense that 
formcomponentpanel.validaterequiredrawinput() always returns true - because 
like you said yourself: it has no raw input of its own.

its final required check will be performed in FormCOmponent#validate() on the 
following lines

convertInput();
if (isValid() && isRequired() && getConvertedInput() == null && 
isInputNullable())
{
  reportRequiredError();
}

which should be the only valid required check for the fcp. makes more sense now?





> FormComponent#checkRequired should implement only the input check
> -----------------------------------------------------------------
>
>                 Key: WICKET-839
>                 URL: https://issues.apache.org/jira/browse/WICKET-839
>             Project: Wicket
>          Issue Type: Bug
>    Affects Versions: 1.3.0-beta2
>            Reporter: Eelco Hillenius
>            Assignee: Eelco Hillenius
>             Fix For: 1.3.0-beta3
>
>
> Currently, checkRequired starts with calling isRequired(), so that method is 
> actually doing two things where it should do one. The check should be done 
> before the method is called in validateRequired instead
> Currently the multiply example in wicket-examples/forminput would have to 
> have the check implemented like this:
>       public boolean checkRequired()
>       {
>               return isRequired() ? left.setRequired(true).checkRequired() &&
>                               right.setRequired(true).checkRequired() : true;
>       }
> which is a pretty ugly hack, while after the change, it can be coded like 
> this:
>       public boolean checkRequired()
>       {
>               return left.checkRequired() && right.checkRequired();
>       }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to