You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Igor Vaynberg (JIRA)" <ji...@apache.org> on 2009/02/01 04:31:02 UTC

[jira] Resolved: (WICKET-1995) Method called unnecessarily in FormComponent

     [ https://issues.apache.org/jira/browse/WICKET-1995?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg resolved WICKET-1995.
-----------------------------------

       Resolution: Fixed
    Fix Version/s: 1.4-RC2
         Assignee: Igor Vaynberg

thanks, in the future it is preferrable to provide code changes via patches.

> Method called unnecessarily in FormComponent
> --------------------------------------------
>
>                 Key: WICKET-1995
>                 URL: https://issues.apache.org/jira/browse/WICKET-1995
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.4-RC1
>         Environment: all
>            Reporter: bernard
>            Assignee: Igor Vaynberg
>            Priority: Minor
>             Fix For: 1.4-RC2
>
>
> In class FormComponent, in method validate(), isValid() is called too many times.
> The last call can be removed by refactoring as follows:
> Original 1.4 code:
> 	public void validate()
> 	{
> 		validateRequired();
> 		if (isValid())
> 		{
> 			convertInput();
> 			if (isValid() && isRequired() && getConvertedInput() == null && isInputNullable())
> 			{
> 				reportRequiredError();
> 			}
> 			if (isValid())
> 			{
> 				validateValidators();
> 			}
> 		}
> 	}
> Refactored:
> 	public void validate()
> 	{
> 		validateRequired();
> 		if (isValid())
> 		{
> 			convertInput();
> 			if(isValid())
> 			{
> 				// Check again because we think that convertInput() can set
> 				// input to null after validateRequired() found valid input.
> 				// When can convertInput() set input to null again?
> 				if (isRequired() && getConvertedInput() == null && isInputNullable())
> 				{
> 					reportRequiredError();
> 				}
> 				else
> 				{
> 					validateValidators();
> 				}
> 			}
> 		}
> 	}

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