You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Peter Parson (JIRA)" <ji...@apache.org> on 2011/03/14 17:26:30 UTC

[jira] Created: (WICKET-3534) Ajax components: provide a DummyAjaxRequestTarget instead of null if Ajax is not available, e.g. to onClick(AjaxRequestTarget)

Ajax components: provide a DummyAjaxRequestTarget instead of null if Ajax is not available, e.g. to onClick(AjaxRequestTarget) 
-------------------------------------------------------------------------------------------------------------------------------

                 Key: WICKET-3534
                 URL: https://issues.apache.org/jira/browse/WICKET-3534
             Project: Wicket
          Issue Type: Wish
          Components: wicket-core
            Reporter: Peter Parson
            Priority: Minor


It is a common pitfall not to think of AjaxRequestTarget maybe being null, e.g. in a Link's onClick method.
Even if the developer has this fact in mind, it is the same piece of code used to avoid NullPointerExceptions or other problems arising of it.

Wouldn't it be nice to have sort of a DummyAjaxRequestTarget? This could solve some common problems:
* NullPointerException due to the passed AjaxRequestTarget being null
* NullPointerExceptions due to AjaxRequestTarget#getPage() returning null
there are probably more.

Also, it would be possible to throw more distinct Exceptions in cases where DummyAjaxRequestTarget cannot handle method calls.

I would love it, for better readibility and less runtime exceptions (even more as these runtime exceptions are only thrown under special conditions: js deactivated or similar)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Commented: (WICKET-3534) Ajax components: provide a DummyAjaxRequestTarget instead of null if Ajax is not available, e.g. to onClick(AjaxRequestTarget)

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

Martin Grigorov commented on WICKET-3534:
-----------------------------------------

By using Optional<AjaxRequestTarget> the developer cannot forget the check. Without the check the code cannot compile at all.
See WICKET-3317.

I think this ticket can be closed as duplicate of WICKET-3317.

> Ajax components: provide a DummyAjaxRequestTarget instead of null if Ajax is not available, e.g. to onClick(AjaxRequestTarget) 
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-3534
>                 URL: https://issues.apache.org/jira/browse/WICKET-3534
>             Project: Wicket
>          Issue Type: Wish
>          Components: wicket-core
>            Reporter: Peter Parson
>            Priority: Minor
>              Labels: ajax, null, nullpointerexception
>
> It is a common pitfall not to think of AjaxRequestTarget maybe being null, e.g. in a Link's onClick method.
> Even if the developer has this fact in mind, it is the same piece of code used to avoid NullPointerExceptions or other problems arising of it.
> Wouldn't it be nice to have sort of a DummyAjaxRequestTarget? This could solve some common problems:
> * NullPointerException due to the passed AjaxRequestTarget being null
> * NullPointerExceptions due to AjaxRequestTarget#getPage() returning null
> there are probably more.
> Also, it would be possible to throw more distinct Exceptions in cases where DummyAjaxRequestTarget cannot handle method calls.
> I would love it, for better readibility and less runtime exceptions (even more as these runtime exceptions are only thrown under special conditions: js deactivated or similar)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Commented: (WICKET-3534) Ajax components: provide a DummyAjaxRequestTarget instead of null if Ajax is not available, e.g. to onClick(AjaxRequestTarget)

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

Peter Parson commented on WICKET-3534:
--------------------------------------

That would be an option, too. Yes.

But I am not of your opinion regarding to whether the developer should know: I think the developer must be *able to* find out whether or not, but they should not *have to* know.

In what I guess are 99% of the cases, developers are repeatedly typing (or forgetting to type ;-)
if(target != null) target.addComponent(myComponent)
without being in need of an "else"

So in my opinion, passing sort of AjaxRequestTarget.EMPTY it would be an easy way to find out whether it's an Ajax request, still avoiding the odd NullPointerException. 



> Ajax components: provide a DummyAjaxRequestTarget instead of null if Ajax is not available, e.g. to onClick(AjaxRequestTarget) 
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-3534
>                 URL: https://issues.apache.org/jira/browse/WICKET-3534
>             Project: Wicket
>          Issue Type: Wish
>          Components: wicket-core
>            Reporter: Peter Parson
>            Priority: Minor
>              Labels: ajax, null, nullpointerexception
>
> It is a common pitfall not to think of AjaxRequestTarget maybe being null, e.g. in a Link's onClick method.
> Even if the developer has this fact in mind, it is the same piece of code used to avoid NullPointerExceptions or other problems arising of it.
> Wouldn't it be nice to have sort of a DummyAjaxRequestTarget? This could solve some common problems:
> * NullPointerException due to the passed AjaxRequestTarget being null
> * NullPointerExceptions due to AjaxRequestTarget#getPage() returning null
> there are probably more.
> Also, it would be possible to throw more distinct Exceptions in cases where DummyAjaxRequestTarget cannot handle method calls.
> I would love it, for better readibility and less runtime exceptions (even more as these runtime exceptions are only thrown under special conditions: js deactivated or similar)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Closed: (WICKET-3534) Ajax components: provide a DummyAjaxRequestTarget instead of null if Ajax is not available, e.g. to onClick(AjaxRequestTarget)

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

Igor Vaynberg closed WICKET-3534.
---------------------------------

    Resolution: Duplicate
      Assignee: Igor Vaynberg

> Ajax components: provide a DummyAjaxRequestTarget instead of null if Ajax is not available, e.g. to onClick(AjaxRequestTarget) 
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-3534
>                 URL: https://issues.apache.org/jira/browse/WICKET-3534
>             Project: Wicket
>          Issue Type: Wish
>          Components: wicket-core
>            Reporter: Peter Parson
>            Assignee: Igor Vaynberg
>            Priority: Minor
>              Labels: ajax, null, nullpointerexception
>
> It is a common pitfall not to think of AjaxRequestTarget maybe being null, e.g. in a Link's onClick method.
> Even if the developer has this fact in mind, it is the same piece of code used to avoid NullPointerExceptions or other problems arising of it.
> Wouldn't it be nice to have sort of a DummyAjaxRequestTarget? This could solve some common problems:
> * NullPointerException due to the passed AjaxRequestTarget being null
> * NullPointerExceptions due to AjaxRequestTarget#getPage() returning null
> there are probably more.
> Also, it would be possible to throw more distinct Exceptions in cases where DummyAjaxRequestTarget cannot handle method calls.
> I would love it, for better readibility and less runtime exceptions (even more as these runtime exceptions are only thrown under special conditions: js deactivated or similar)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Commented: (WICKET-3534) Ajax components: provide a DummyAjaxRequestTarget instead of null if Ajax is not available, e.g. to onClick(AjaxRequestTarget)

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

Igor Vaynberg commented on WICKET-3534:
---------------------------------------

i think the developer should know if they are in an ajax request or not, and the way to test that is to check for target==null. rather then providing this dummy target we should wrap the passed in ajaxrequesttarget in Optional<AjaxRequestTarget> to make explicit that it can be null.

> Ajax components: provide a DummyAjaxRequestTarget instead of null if Ajax is not available, e.g. to onClick(AjaxRequestTarget) 
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-3534
>                 URL: https://issues.apache.org/jira/browse/WICKET-3534
>             Project: Wicket
>          Issue Type: Wish
>          Components: wicket-core
>            Reporter: Peter Parson
>            Priority: Minor
>              Labels: ajax, null, nullpointerexception
>
> It is a common pitfall not to think of AjaxRequestTarget maybe being null, e.g. in a Link's onClick method.
> Even if the developer has this fact in mind, it is the same piece of code used to avoid NullPointerExceptions or other problems arising of it.
> Wouldn't it be nice to have sort of a DummyAjaxRequestTarget? This could solve some common problems:
> * NullPointerException due to the passed AjaxRequestTarget being null
> * NullPointerExceptions due to AjaxRequestTarget#getPage() returning null
> there are probably more.
> Also, it would be possible to throw more distinct Exceptions in cases where DummyAjaxRequestTarget cannot handle method calls.
> I would love it, for better readibility and less runtime exceptions (even more as these runtime exceptions are only thrown under special conditions: js deactivated or similar)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira