You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Petr Sakar (JIRA)" <ji...@apache.org> on 2008/03/11 23:34:46 UTC

[jira] Created: (WICKET-1414) findSubmittingButton will fail when button without form is added before form

findSubmittingButton will fail when button without form is added before form
----------------------------------------------------------------------------

                 Key: WICKET-1414
                 URL: https://issues.apache.org/jira/browse/WICKET-1414
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.3.1
            Reporter: Petr Sakar
            Priority: Minor


Form submitting button is not found when page contains another button, which is not part of form and is added to the page hierarchy before form. When it is added after the form, it is working. The problem is in the method of Form class:

	public final IFormSubmittingComponent findSubmittingButton()
	{
		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent) getPage().visitChildren(
			IFormSubmittingComponent.class, new IVisitor()

which is serching for the submitting button in the whole page instead of the form only. I think correctly should be

	public final IFormSubmittingComponent findSubmittingButton()
	{
		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent)visitChildren(
			IFormSubmittingComponent.class, new IVisitor()



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


[jira] Reopened: (WICKET-1414) findSubmittingButton will fail when button without form is added before form

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1414?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg reopened WICKET-1414:
-----------------------------------

      Assignee: Johan Compagner  (was: Igor Vaynberg)

> findSubmittingButton will fail when button without form is added before form
> ----------------------------------------------------------------------------
>
>                 Key: WICKET-1414
>                 URL: https://issues.apache.org/jira/browse/WICKET-1414
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.1
>            Reporter: Petr Sakar
>            Assignee: Johan Compagner
>            Priority: Minor
>             Fix For: 1.3.3
>
>         Attachments: myproject.zip, myproject.zip
>
>
> Form submitting button is not found when page contains another button, which is not part of form and is added to the page hierarchy before form. When it is added after the form, it is working. The problem is in the method of Form class:
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent) getPage().visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()
> which is serching for the submitting button in the whole page instead of the form only. I think correctly should be
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent)visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()

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


[jira] Updated: (WICKET-1414) findSubmittingButton will fail when button without form is added before form

Posted by "Petr Sakar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1414?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Petr Sakar updated WICKET-1414:
-------------------------------

    Attachment: myproject.zip

mvn packege fails on second test. Form contains correct type of button now

> findSubmittingButton will fail when button without form is added before form
> ----------------------------------------------------------------------------
>
>                 Key: WICKET-1414
>                 URL: https://issues.apache.org/jira/browse/WICKET-1414
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.1
>            Reporter: Petr Sakar
>            Assignee: Igor Vaynberg
>            Priority: Minor
>             Fix For: 1.3.3
>
>         Attachments: myproject.zip, myproject.zip
>
>
> Form submitting button is not found when page contains another button, which is not part of form and is added to the page hierarchy before form. When it is added after the form, it is working. The problem is in the method of Form class:
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent) getPage().visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()
> which is serching for the submitting button in the whole page instead of the form only. I think correctly should be
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent)visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()

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


[jira] Commented: (WICKET-1414) findSubmittingButton will fail when button without form is added before form

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1414?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581377#action_12581377 ] 

Johan Compagner commented on WICKET-1414:
-----------------------------------------

what i find strange is why your button that is before the form is passing this if:

if (submittingComponent.getForm() != null &&
						submittingComponent.getForm().getRootForm() == Form.this &&
						(getRequest().getParameter(submittingComponent.getInputName()) != null || getRequest().getParameter(
							submittingComponent.getInputName() + ".x") != null)

first of all your button is outside the form right?
So that buttons value isn't submitted, so why is there a request param that is exactly the input name of that component??
Do you have 2 buttons one in the form 1 outside of the form (that still has that form as its root form) with the same name?

> findSubmittingButton will fail when button without form is added before form
> ----------------------------------------------------------------------------
>
>                 Key: WICKET-1414
>                 URL: https://issues.apache.org/jira/browse/WICKET-1414
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.1
>            Reporter: Petr Sakar
>            Assignee: Igor Vaynberg
>            Priority: Minor
>             Fix For: 1.3.3
>
>         Attachments: myproject.zip, myproject.zip
>
>
> Form submitting button is not found when page contains another button, which is not part of form and is added to the page hierarchy before form. When it is added after the form, it is working. The problem is in the method of Form class:
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent) getPage().visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()
> which is serching for the submitting button in the whole page instead of the form only. I think correctly should be
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent)visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()

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


[jira] Commented: (WICKET-1414) findSubmittingButton will fail when button without form is added before form

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1414?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581393#action_12581393 ] 

Johan Compagner commented on WICKET-1414:
-----------------------------------------

ok then the fix should be
that getForm() doesn't throw an exception...

it doesnt do that for submit link:

	public Form getForm()
	{
		if (form != null)
		{
			return form;
		}
		else
		{
			return (Form)findParent(Form.class);
		}
	}


but it does for Button (and its subclasses) because that uses the getForm() from FormComponent

	public Form getForm()
	{
		class FindFormVisitor implements Component.IVisitor
		{
			Form form = null;

			public Object component(Component component)
			{
				form = (Form)component;
				return Component.IVisitor.STOP_TRAVERSAL;
			}
		}

		Form form = (Form)findParent(Form.class);
		if (form == null)
		{
			// check whether the form is a child of a surrounding border
			final Border border = (Border)findParent(Border.class);
			if (border != null)
			{
				FindFormVisitor formVisitor = new FindFormVisitor();
				border.visitChildren(Form.class, formVisitor);
				form = formVisitor.form;
			}
			if (form == null)
			{
				throw new WicketRuntimeException("Could not find Form parent for " + this);
			}
		}
		return form;
	}

and we expect in the code i past that getForm() just return null and not an exception.
so i guess what we can do is let Button override getForm() just like SubmitLink

Then Button is is a FormComponent that doesn't throw an exception. but i dont see a big problem with that? Igor?

> findSubmittingButton will fail when button without form is added before form
> ----------------------------------------------------------------------------
>
>                 Key: WICKET-1414
>                 URL: https://issues.apache.org/jira/browse/WICKET-1414
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.1
>            Reporter: Petr Sakar
>            Assignee: Igor Vaynberg
>            Priority: Minor
>             Fix For: 1.3.3
>
>         Attachments: myproject.zip, myproject.zip
>
>
> Form submitting button is not found when page contains another button, which is not part of form and is added to the page hierarchy before form. When it is added after the form, it is working. The problem is in the method of Form class:
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent) getPage().visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()
> which is serching for the submitting button in the whole page instead of the form only. I think correctly should be
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent)visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()

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


[jira] Commented: (WICKET-1414) findSubmittingButton will fail when button without form is added before form

Posted by "Petr Sakar (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1414?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581391#action_12581391 ] 

Petr Sakar commented on WICKET-1414:
------------------------------------

Johan, as Igor noted, normally it should not happed, I did it and thus found it by mistake.

To explain in detail:  

The buttons have different name. The component tree is either

page without error
  Label message 
  Form form
     Button button1 (child of form)
  Button button2 (child of page)

or

page with error (in code switched order of adding, html exactly the same)
  Label message 
  Button button2 (child of page)
  Form form
     Button button1 (child of form)

The error is because when form is searching for submitting component, it searches through all components of page and calls getForm() method of button2, which throws exception. On page without error the button1 is found, so it will not reach button2 and can not throw exception ...

I think the correct solution would be either to disallow to add button (meant IFormSubmittingComponent) without parent form, or ignore such button during search, or partial solution suggested above. But again, under normal conditions it should not happen. I do not have any idea if it is valid in HTML/XHTML have button without form ...


> findSubmittingButton will fail when button without form is added before form
> ----------------------------------------------------------------------------
>
>                 Key: WICKET-1414
>                 URL: https://issues.apache.org/jira/browse/WICKET-1414
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.1
>            Reporter: Petr Sakar
>            Assignee: Igor Vaynberg
>            Priority: Minor
>             Fix For: 1.3.3
>
>         Attachments: myproject.zip, myproject.zip
>
>
> Form submitting button is not found when page contains another button, which is not part of form and is added to the page hierarchy before form. When it is added after the form, it is working. The problem is in the method of Form class:
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent) getPage().visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()
> which is serching for the submitting button in the whole page instead of the form only. I think correctly should be
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent)visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()

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


[jira] Updated: (WICKET-1414) findSubmittingButton will fail when button without form is added before form

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1414?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg updated WICKET-1414:
----------------------------------

    Fix Version/s: 1.3.3
         Assignee: Gerolf Seitz

> findSubmittingButton will fail when button without form is added before form
> ----------------------------------------------------------------------------
>
>                 Key: WICKET-1414
>                 URL: https://issues.apache.org/jira/browse/WICKET-1414
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.1
>            Reporter: Petr Sakar
>            Assignee: Gerolf Seitz
>            Priority: Minor
>             Fix For: 1.3.3
>
>         Attachments: myproject.zip
>
>
> Form submitting button is not found when page contains another button, which is not part of form and is added to the page hierarchy before form. When it is added after the form, it is working. The problem is in the method of Form class:
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent) getPage().visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()
> which is serching for the submitting button in the whole page instead of the form only. I think correctly should be
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent)visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()

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


[jira] Commented: (WICKET-1414) findSubmittingButton will fail when button without form is added before form

Posted by "Petr Sakar (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1414?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581354#action_12581354 ] 

Petr Sakar commented on WICKET-1414:
------------------------------------

Igor,
you are totally right in your statements. I'm do not want to use button without the form normally, I've used it only by mistake. It lead to this strange behavior, so I was just carious why it is working in one case and in second not.

My point is if I use this button without the form in front of valid form, the valid form is not working, if it's after, it is working. The reason is you are searching for submitting component in whole page.

one) If  button outside the form is not supported, would be nice to issue some warning or exception

two) i do not know if submittingButton in form can be outside of form on not. In case that not, it does not make sense to search for it in whole page, should be searched only in form. In case you have page with lot of components it can bring significant speed improvement.

Do you have any example, where the submitting button is outside the form (by your first statement it should not exist) ? If it can not be outside the form, should not be any problem to search only in form scope instead of page scope.


> findSubmittingButton will fail when button without form is added before form
> ----------------------------------------------------------------------------
>
>                 Key: WICKET-1414
>                 URL: https://issues.apache.org/jira/browse/WICKET-1414
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.1
>            Reporter: Petr Sakar
>            Assignee: Igor Vaynberg
>            Priority: Minor
>             Fix For: 1.3.3
>
>         Attachments: myproject.zip
>
>
> Form submitting button is not found when page contains another button, which is not part of form and is added to the page hierarchy before form. When it is added after the form, it is working. The problem is in the method of Form class:
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent) getPage().visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()
> which is serching for the submitting button in the whole page instead of the form only. I think correctly should be
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent)visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()

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


[jira] Updated: (WICKET-1414) findSubmittingButton will fail when button without form is added before form

Posted by "Petr Sakar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1414?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Petr Sakar updated WICKET-1414:
-------------------------------

    Attachment: myproject.zip

project created from quick start containing 2 pages illustrating the problem and unit tests, which should pass, but one of them fails.

> findSubmittingButton will fail when button without form is added before form
> ----------------------------------------------------------------------------
>
>                 Key: WICKET-1414
>                 URL: https://issues.apache.org/jira/browse/WICKET-1414
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.1
>            Reporter: Petr Sakar
>            Priority: Minor
>         Attachments: myproject.zip
>
>
> Form submitting button is not found when page contains another button, which is not part of form and is added to the page hierarchy before form. When it is added after the form, it is working. The problem is in the method of Form class:
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent) getPage().visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()
> which is serching for the submitting button in the whole page instead of the form only. I think correctly should be
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent)visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()

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


[jira] Commented: (WICKET-1414) findSubmittingButton will fail when button without form is added before form

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1414?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581357#action_12581357 ] 

Igor Vaynberg commented on WICKET-1414:
---------------------------------------

your first example did nothing for me either. since both were <button type="button"> tags the form was never submitted.

there are a few usecases where a submitting component can be outside a form. see SubmitLink, AjaxSubmitLink, AjaxButton.

-igor


> findSubmittingButton will fail when button without form is added before form
> ----------------------------------------------------------------------------
>
>                 Key: WICKET-1414
>                 URL: https://issues.apache.org/jira/browse/WICKET-1414
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.1
>            Reporter: Petr Sakar
>            Assignee: Igor Vaynberg
>            Priority: Minor
>             Fix For: 1.3.3
>
>         Attachments: myproject.zip
>
>
> Form submitting button is not found when page contains another button, which is not part of form and is added to the page hierarchy before form. When it is added after the form, it is working. The problem is in the method of Form class:
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent) getPage().visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()
> which is serching for the submitting button in the whole page instead of the form only. I think correctly should be
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent)visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()

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


[jira] Closed: (WICKET-1414) findSubmittingButton will fail when button without form is added before form

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1414?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Johan Compagner closed WICKET-1414.
-----------------------------------

    Resolution: Fixed

Button.getForm() will not throw an exception

> findSubmittingButton will fail when button without form is added before form
> ----------------------------------------------------------------------------
>
>                 Key: WICKET-1414
>                 URL: https://issues.apache.org/jira/browse/WICKET-1414
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.1
>            Reporter: Petr Sakar
>            Assignee: Johan Compagner
>            Priority: Minor
>             Fix For: 1.3.3
>
>         Attachments: myproject.zip, myproject.zip
>
>
> Form submitting button is not found when page contains another button, which is not part of form and is added to the page hierarchy before form. When it is added after the form, it is working. The problem is in the method of Form class:
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent) getPage().visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()
> which is serching for the submitting button in the whole page instead of the form only. I think correctly should be
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent)visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()

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


[jira] Resolved: (WICKET-1414) findSubmittingButton will fail when button without form is added before form

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1414?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg resolved WICKET-1414.
-----------------------------------

    Resolution: Invalid

there are a couple of things wrong with your example.

one) button outside the form is not supported and is not a proper use of the component. Link is the proper component to use here (and can be attached to <button> tag) or a SubmitLink if you need to submit the form from outside.

two) <button type="button"> is not meant to submit a form. you can try type="submit" if its inside the form, or add javascript to onlick ( which is what Link attached to <button> does)

> findSubmittingButton will fail when button without form is added before form
> ----------------------------------------------------------------------------
>
>                 Key: WICKET-1414
>                 URL: https://issues.apache.org/jira/browse/WICKET-1414
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.1
>            Reporter: Petr Sakar
>            Assignee: Igor Vaynberg
>            Priority: Minor
>             Fix For: 1.3.3
>
>         Attachments: myproject.zip
>
>
> Form submitting button is not found when page contains another button, which is not part of form and is added to the page hierarchy before form. When it is added after the form, it is working. The problem is in the method of Form class:
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent) getPage().visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()
> which is serching for the submitting button in the whole page instead of the form only. I think correctly should be
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent)visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()

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


[jira] Assigned: (WICKET-1414) findSubmittingButton will fail when button without form is added before form

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-1414?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg reassigned WICKET-1414:
-------------------------------------

    Assignee: Igor Vaynberg  (was: Gerolf Seitz)

> findSubmittingButton will fail when button without form is added before form
> ----------------------------------------------------------------------------
>
>                 Key: WICKET-1414
>                 URL: https://issues.apache.org/jira/browse/WICKET-1414
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.1
>            Reporter: Petr Sakar
>            Assignee: Igor Vaynberg
>            Priority: Minor
>             Fix For: 1.3.3
>
>         Attachments: myproject.zip
>
>
> Form submitting button is not found when page contains another button, which is not part of form and is added to the page hierarchy before form. When it is added after the form, it is working. The problem is in the method of Form class:
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent) getPage().visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()
> which is serching for the submitting button in the whole page instead of the form only. I think correctly should be
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent)visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()

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


[jira] Commented: (WICKET-1414) findSubmittingButton will fail when button without form is added before form

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1414?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581394#action_12581394 ] 

Johan Compagner commented on WICKET-1414:
-----------------------------------------

i will check this in if nobody has a problem with it:

Button.	public Form getForm()
	{
		try
		{
			return super.getForm();
		}
		catch (WicketRuntimeException wre)
		{
			// ignore this and return null. (Form.findSubmittingComponent expects this)
		}
		return null;
	}

(i do this because there is some special code for borders in getform of formcomponent that i dont want to completely copy.)

> findSubmittingButton will fail when button without form is added before form
> ----------------------------------------------------------------------------
>
>                 Key: WICKET-1414
>                 URL: https://issues.apache.org/jira/browse/WICKET-1414
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.1
>            Reporter: Petr Sakar
>            Assignee: Igor Vaynberg
>            Priority: Minor
>             Fix For: 1.3.3
>
>         Attachments: myproject.zip, myproject.zip
>
>
> Form submitting button is not found when page contains another button, which is not part of form and is added to the page hierarchy before form. When it is added after the form, it is working. The problem is in the method of Form class:
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent) getPage().visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()
> which is serching for the submitting button in the whole page instead of the form only. I think correctly should be
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent)visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()

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


[jira] Commented: (WICKET-1414) findSubmittingButton will fail when button without form is added before form

Posted by "Petr Sakar (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-1414?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12581369#action_12581369 ] 

Petr Sakar commented on WICKET-1414:
------------------------------------

Igor,
I do not know if it make sense for you or not, the solution would be to search in form first, and if nothing found in page. The first search would be successful for all submits by form children (most of cases), second would catch components outside form. Advantege - quicker in first case, disadvantage - it's a change and slower in second case.

	/**
	 * Gets the IFormSubmittingComponent which submitted this form.
	 * 
	 * @return The component which submitted this form, or null if the processing was not triggered
	 *         by a registered IFormSubmittingComponent
	 */
	public final IFormSubmittingComponent findSubmittingButton()
	{
		IVisitor visitor = new IVisitor()
		{
			public Object component(final Component component)
			{
				// Get submitting component
				final IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent)component;

				// Check for component-name or component-name.x request string
				if (submittingComponent.getForm() != null &&
					submittingComponent.getForm().getRootForm() == Form.this &&
					(getRequest().getParameter(submittingComponent.getInputName()) != null || getRequest().getParameter(
						submittingComponent.getInputName() + ".x") != null))
				{
					if (!component.isVisible())
					{
						throw new WicketRuntimeException("Submit Button " +
							submittingComponent.getInputName() + " (path=" +
							component.getPageRelativePath() + ") is not visible");
					}
					return submittingComponent;
				}
				return CONTINUE_TRAVERSAL;
			}
		};
		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent)visitChildren(
			IFormSubmittingComponent.class, visitor);
		if (submittingComponent == null)
			submittingComponent = (IFormSubmittingComponent)getPage().visitChildren(
				IFormSubmittingComponent.class, visitor);
		return submittingComponent;
	}


> findSubmittingButton will fail when button without form is added before form
> ----------------------------------------------------------------------------
>
>                 Key: WICKET-1414
>                 URL: https://issues.apache.org/jira/browse/WICKET-1414
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.1
>            Reporter: Petr Sakar
>            Assignee: Igor Vaynberg
>            Priority: Minor
>             Fix For: 1.3.3
>
>         Attachments: myproject.zip, myproject.zip
>
>
> Form submitting button is not found when page contains another button, which is not part of form and is added to the page hierarchy before form. When it is added after the form, it is working. The problem is in the method of Form class:
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent) getPage().visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()
> which is serching for the submitting button in the whole page instead of the form only. I think correctly should be
> 	public final IFormSubmittingComponent findSubmittingButton()
> 	{
> 		IFormSubmittingComponent submittingComponent = (IFormSubmittingComponent)visitChildren(
> 			IFormSubmittingComponent.class, new IVisitor()

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