You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by ageery <gi...@git.apache.org> on 2017/01/30 21:28:22 UTC

[GitHub] wicket pull request #209: Add static lambda builder methods.

GitHub user ageery opened a pull request:

    https://github.com/apache/wicket/pull/209

    Add static lambda builder methods.

    For ListView, added a static factory that creates a ListView with a lambda (for populateItem).
    For WebApplication, added a static factory that allows the home page class to be specified and allows a lambda to be specified for the init() method.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ageery/wicket master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/wicket/pull/209.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #209
    
----
commit bfc3272422a72e847b2b67801b3b6480e41713c1
Author: ageery <an...@gmail.com>
Date:   2017-01-30T21:25:35Z

    Add static lambda builder methods.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] wicket pull request #209: Add static lambda builder methods.

Posted by martin-g <gi...@git.apache.org>.
Github user martin-g commented on a diff in the pull request:

    https://github.com/apache/wicket/pull/209#discussion_r98612128
  
    --- Diff: wicket-core/src/main/java/org/apache/wicket/markup/html/list/ListView.java ---
    @@ -652,4 +653,24 @@ public final void setModelObject(List<T> object)
     	{
     		setDefaultModelObject(object);
     	}
    +
    +	/**
    +	 * Returns a new ListVIew
    +	 * @param id component id
    +	 * @param model model containing a list of items
    +	 * @param consumer lambda to use for populating the ListView
    +	 * @param <T> type of the items in the model
    +	 * @return a new ListView
    +	 */
    +	public static <T> ListView<T> populateItem(final String id, final IModel<? extends List<T>> model, final SerializableConsumer<ListItem<T>> consumer) {
    --- End diff --
    
    For some reason I don't like the name of the method. It doesn't fit well for this factory method. But I don't have a better one at the moment.
    Also it should be added to org.apache.wicket.lambda.Lambdas


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] wicket pull request #209: Add static lambda builder methods.

Posted by ageery <gi...@git.apache.org>.
Github user ageery commented on a diff in the pull request:

    https://github.com/apache/wicket/pull/209#discussion_r99799884
  
    --- Diff: wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java ---
    @@ -1074,4 +1074,39 @@ public boolean getUpdateAutoLabelsOnAjaxRequests()
     	{
     		return true;
     	}
    +
    +	/**
    +	 * Returns a new web application.
    +	 * @param homePageClass Home page class
    +	 * @return new web application
    +	 */
    +	public static WebApplication newWebApp(final Class<? extends Page> homePageClass) {
    +		return newWebApp(homePageClass, null);
    +	}
    +
    +	/**
    +	 * Returns a new web application.
    +	 * @param homePageClass Home page class
    +	 * @param initConsumer  Lambda for initializing the web application
    +	 * @return new web application
    +	 */
    +	public static WebApplication newWebApp(final Class<? extends Page> homePageClass, final SerializableConsumer<WebApplication> initConsumer) {
    --- End diff --
    
    I was thinking of the Wicket-Spring Boot library which has a dedicated interface for this use-case [1].  From a Spring Boot perspective, I was thinking of something building an application up like this:
    
        @Bean public Class<? extends Page> getHomePageClass() { ... }
        @Bean public SerializableConsumer<WebApplication> getWebAppInit() { ... }
        @Bean public WebApplication getWebApplication(Class<? extends page> homePageClass, SerializableConsumer<WebApplication> init) { 
            return WebApplication.newWebApp(homePageClass, init); 
        }
    
    [1] https://github.com/MarcGiffing/wicket-spring-boot/blob/0c67011b887d25ffab10866016100754b204990c/wicket-spring-boot-context/src/main/java/com/giffing/wicket/spring/boot/context/extensions/WicketApplicationInitConfiguration.java


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] wicket issue #209: Add static lambda builder methods.

Posted by martin-g <gi...@git.apache.org>.
Github user martin-g commented on the issue:

    https://github.com/apache/wicket/pull/209
  
    @ageery Please close this PR. As per last discussions and votes it seems such lambda helpers won't be in Wicket Core for now.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] wicket issue #209: Add static lambda builder methods.

Posted by martin-g <gi...@git.apache.org>.
Github user martin-g commented on the issue:

    https://github.com/apache/wicket/pull/209
  
    @ageery You might want to participate at this discussion: http://markmail.org/message/q4gb57wmyrkkbr2s


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] wicket pull request #209: Add static lambda builder methods.

Posted by martin-g <gi...@git.apache.org>.
Github user martin-g commented on a diff in the pull request:

    https://github.com/apache/wicket/pull/209#discussion_r98612314
  
    --- Diff: wicket-core/src/main/java/org/apache/wicket/protocol/http/WebApplication.java ---
    @@ -1074,4 +1074,39 @@ public boolean getUpdateAutoLabelsOnAjaxRequests()
     	{
     		return true;
     	}
    +
    +	/**
    +	 * Returns a new web application.
    +	 * @param homePageClass Home page class
    +	 * @return new web application
    +	 */
    +	public static WebApplication newWebApp(final Class<? extends Page> homePageClass) {
    +		return newWebApp(homePageClass, null);
    +	}
    +
    +	/**
    +	 * Returns a new web application.
    +	 * @param homePageClass Home page class
    +	 * @param initConsumer  Lambda for initializing the web application
    +	 * @return new web application
    +	 */
    +	public static WebApplication newWebApp(final Class<? extends Page> homePageClass, final SerializableConsumer<WebApplication> initConsumer) {
    --- End diff --
    
    I don't imagine a good use case where someone would like to use an anonymous instance of WebApplication.
    This is useful only for mini applications like the quickstart. But any real application most definitely will need a proper specialization and its own logic.  


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] wicket pull request #209: Add static lambda builder methods.

Posted by ageery <gi...@git.apache.org>.
Github user ageery commented on a diff in the pull request:

    https://github.com/apache/wicket/pull/209#discussion_r99798858
  
    --- Diff: wicket-core/src/main/java/org/apache/wicket/markup/html/list/ListView.java ---
    @@ -652,4 +653,24 @@ public final void setModelObject(List<T> object)
     	{
     		setDefaultModelObject(object);
     	}
    +
    +	/**
    +	 * Returns a new ListVIew
    +	 * @param id component id
    +	 * @param model model containing a list of items
    +	 * @param consumer lambda to use for populating the ListView
    +	 * @param <T> type of the items in the model
    +	 * @return a new ListView
    +	 */
    +	public static <T> ListView<T> populateItem(final String id, final IModel<? extends List<T>> model, final SerializableConsumer<ListItem<T>> consumer) {
    --- End diff --
    
    Instead of populateItem(...) how about listView(...) -- make the static mirror the class name?
    
    The Lambdas class is interesting!  I had missed that before...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] wicket pull request #209: Add static lambda builder methods.

Posted by ageery <gi...@git.apache.org>.
Github user ageery closed the pull request at:

    https://github.com/apache/wicket/pull/209


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---