Skip to content

Added ControllerActionBuilder with actionFor method. #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from

Conversation

dschulten
Copy link
Contributor

Improved support for requests which require that the client sends data to the server. The goal is not to rely on out-of-band information for this.

The new ActionDescriptor allows to create responses which tell the client how to send data to a resource, e.g. how to build POST and PUT bodies or which GET parameters to use in a query.

See the javadoc of ControllerActionBuilder and HtmlResourceMessageConverter for usage and SamplePersonController and HtmlResourceMessageConverterTest-context.xml for an example.
Currently using spring-test-mvc with WebContextLoader to stay compatible with Spring 3.1.x

dschulten added 2 commits May 18, 2013 19:36
See the javadoc of ControllerActionBuilder and HtmlResourceMessageConverter for usage and SamplePersonController and HtmlResourceMessageConverterTest-context.xml for an example.
Currently using spring-test-mvc with WebContextLoader to stay compatible with Spring 3.1.x
removed code duplication in AnnotatedParametersParameterAccessor.getBoundMethodParameterValues
@odrotbohm
Copy link
Member

This looks quite decent. Is there a chance you try to raise the version of the spring-test module to 3.2.3 individually and try to use the Spring 3.2 integration test framework. Although probably a bit weird at first glance I'd like to try this to avoid adding all the custom web test infrastructure code to the codebase.

Once we have that polished I can start polishing the code to get it merged. :)

@dschulten
Copy link
Contributor Author

I tried that already, it didn't work due to class not found errors. That's
why I backported the tests to 3.1 :-)

@odrotbohm
Copy link
Member

Guess what? Just raise the dependency to Spring 3.2.3 then. If one's interested in state-of-the-art hypermedia, you're probably able/willing to upgrade to an up-to-date Spring as well.

@dschulten
Copy link
Contributor Author

OK, I'll do that :-) I'll also change the name createActionFor to
actionFor, if you don't mind.

@odrotbohm
Copy link
Member

Go ahead, I'll probably apply some name changes here and there after some internal feedback here as well. I just wanted to make sure we don't start of with too much extra code in the first place. :)

dschulten added 5 commits June 1, 2013 12:50
Reverted fix for VndErrorsMarshallingTests, will apply the official fix
Conflicts:
	src/main/java/org/springframework/hateoas/mvc/ControllerLinkBuilderFactory.java
	src/test/java/org/springframework/hateoas/mvc/ControllerLinkBuilderUnitTest.java
Removed an incorrect comment stating that PUT will be part of HTML5, it won't be: http://www.w3.org/html/wg/wiki/User:Eoconnor/ISSUE-195
…er returning an array of HttpMessageConverters, not a List
@dschulten
Copy link
Contributor Author

This is how an action could be represented in HAL: https://gist.github.com/dschulten/5696110, single-item form. The idea is, if I am a browser, I will get a form whereas if I am asking for application/hal+json I will get a hal resource.

@felixbarny
Copy link

Any plans on when this is going to be merged?

@felixbarny
Copy link

ping :)

@dschulten
Copy link
Contributor Author

Hi Oliver, are you still interested in this? Is some work needed on my side to get this in?

@aheusingfeld
Copy link

@olivergierke could you please review this. The "method" support would be very much appreciated. Thanks. ;)

@odrotbohm
Copy link
Member

To be honest, the more I look into it, the less I am convinced that merging this is a good idea:

  • we're basically stuck with something quite involved but still very rudimentary. Only @RequestParam is currently supported, no @PathVariable, no @ModelAttribute.
  • ControllerActionBuilder seems to be repeating a lot of code that already exists in the infrastructure and probably only works in the exact use case it was written for (what about proxied requests etc.)

In general, my biggest concern is that this is far from done and basically lacking a description of the general approach, its limitations. We currently don't have neither a form nor HTML strategy with Spring HATEOAS and I think that we need to come up with a more exhaustive concept to it before going forward with it. Open for suggestions.

@dschulten
Copy link
Contributor Author

Since I am the author of that pull request: After the pull request never
made it into spring-hateoas, I have created a LinkBuilder implementation
called AffordanceBuilder [1]
which works as a drop-in replacement for ControllerLinkBuilder. It creates
an Affordance, which is a hateoas Link with additional traits (httpMethod,
RequestParam, RequestBody, multiple methods per rel). It also supports all
features of the RFC5988 Link header.

@olivergierke if you are interested I would be happy to create another pull
request which adds AffordanceBuilder back into spring-hateoas. I'll be at
JAX, maybe we can meet there.
After all, hydra-java stands firmly on the shoulders of spring-hateoas :)
Conceptually, AffordanceBuilder would be a better choice than this pull
request.

The goal of hydra-java is to support hypermedia types with "forms" support,
first hydra, but xhtml and uber converters are coming soon.

[1]
https://github.com/dschulten/hydra-java/blob/master/README.asciidoc#affordancebuilder-for-rich-hyperlinks-from-v-020
[2] https://github.com/dschulten/hydra-java/tree/master/spring-hateoas-ext

Am 09.03.2015 um 01:44 schrieb Alexander Heusingfeld:

@olivergierke https://github.com/olivergierke could you please review
this. The "method" support would be very much appreciated. Thanks. ;)


Reply to this email directly or view it on GitHub
#71 (comment).

@odrotbohm
Copy link
Member

That's great news, Dietrich. As JAX is not too far away anymore. Shall we get together there and find some time to discuss things? Wouldn't mind @aheusingfeld joining us as he seems to be buys in that area, too.

@aheusingfeld
Copy link

I have created a LinkBuilder implementation called AffordanceBuilder [1] which works as a drop-in replacement for ControllerLinkBuilder. It creates an Affordance, which is a hateoas Link with additional traits (httpMethod, RequestParam, RequestBody, multiple methods per rel).

Great! That's almost exactly what I started with yesterday! Will look at your implementation instead. \o/

Wouldn't mind @aheusingfeld joining us as he seems to be buys in that area, too.

Yes. I'll be there Apr 21 - 23. Looking forward to see you there.

@dschulten
Copy link
Contributor Author

My talk is on the 23rd at 17:00-18:00, so best after that or right after
Alexander's talk.

Dietrich

On March 10, 2015 8:08:51 AM Oliver Gierke [email protected] wrote:

That's great news, Dietrich. As JAX is not too far away anymore. Shall we
get together there and find some time to discuss things? Wouldn't mind
@aheusingfeld joining us as he seems to be buys in that area, too.


Reply to this email directly or view it on GitHub:
#71 (comment)

@odrotbohm odrotbohm force-pushed the master branch 2 times, most recently from 4ebc1be to 266ad50 Compare July 25, 2016 18:32
gregturn added a commit that referenced this pull request Aug 15, 2017
* Introduces new Affordances API to build links related to each other to serve other mediatypes
* Introduces HAL-FORMS, which uses affordances to automatically generate HTML form data based on Spring MVC annotations.

Original pull-request: #340, #447, #581
Related issues: #503, #334, #71
gregturn added a commit that referenced this pull request Nov 6, 2017
* Introduces new Affordances API to build links related to each other to serve other mediatypes
* Introduces HAL-FORMS, which uses affordances to automatically generate HTML form data based on Spring MVC annotations.

Original pull-request: #340, #447, #581
Related issues: #503, #334, #71
gregturn added a commit that referenced this pull request Nov 27, 2017
* Introduces new Affordances API to build links related to each other to serve other mediatypes
* Introduces HAL-FORMS, which uses affordances to automatically generate HTML form data based on Spring MVC annotations.

Original pull-request: #340, #447, #581
Related issues: #503, #334, #71
odrotbohm pushed a commit that referenced this pull request Nov 29, 2017
* Introduces new Affordances API to build links related to each other to serve other mediatypes
* Introduces HAL-FORMS, which uses affordances to automatically generate HTML form data based on Spring MVC annotations.

Original pull-request: #340, #447, #581
Related issues: #503, #334, #71
@gregturn
Copy link
Contributor

Superceded by #612 and resolved via 70448a8.

Final solution isn't precisely the same thing, but we plan to iterate over it in the near future and expand to support other mediatypes. Feel free to check the HAL-FORMS section of code and their corresponding unit tests.

Also, see monitor Spring HATEOAS Examples repo as we plan to add an Affordances example very soon.

@gregturn gregturn closed this Nov 29, 2017
@pivotal-issuemaster
Copy link

@dschulten Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

1 similar comment
@pivotal-issuemaster
Copy link

@dschulten Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants