-
Notifications
You must be signed in to change notification settings - Fork 18
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
Determine the possible values for a field #9
Comments
looks pretty good. FWIW, i implemented this pattern for Cj recently (not yet published) and used almost identical elements (didn't use "embedded" property, but that's a minor thing). suggest render optional these are my first comments. feel free to add/discuss here and/or on the HAL list. |
Thanks @mamund for the quick response. suggest render optional |
all cool with the above. also, what i meant w/ saying that |
|
Note that the current implementation includes support for a google-style "type-ahead" UX. From the human UI POV, the name/value pairs could be rendered as an HTML INPUT with type-ahead support (via javascript), HTML SELECT(including multi-select), RADIO, or CHECKBOX elements. The current version doesn't support servers sending hints to the client to TELL them how to render the metadata, tho. Of course, this extension also works well for machine interfaces where the HTML-style rendering is not needed. |
@mamund If we agree on this, would you mind including it as part of the specification? |
not sure i see anything changed to the HAL-FORMS spec. am i missing something? |
In the spec when a form field is described, this is the text:
Isn't "Suggest" supposed to be there with some examples of its use? |
sorry, we've spent so much time on other things! i'll complete it this week. |
In the case of Pointing to a data list in the same resource the suggest object has an
this rel
In the HAL google group posting, that corresponds to the second case where the descriptor
Do I understand correctly that the local data list is in the HAL response, not the hal-forms document? @mamund is there any chance to have an early look at the spec changes for suggest, even if it is just a branch of the hal-forms spec? |
@dschulten Answering your previous question, I believe that the Suggest embedded field should be inside the HAL-FORMS document, it makes sense because the details may only be known at that moment, and it may be different for different resources for example. Moreover it will make it more complex for the client to process it if it has to maintain the HAL response to process HAL-FORMS later (just in case it appears in the Suggest fields) |
@mamund We are testing different situations with Suggest and I discovered one situation that we are not covering right know, and it is the multiple values case. At some point in your discussion you suggested the use of a RENDER field, that could be an option, but I'm more in favor of including a new field like "multi=true" while defining the property. Should we create a new issue for that? |
Yes, add an issue. Good idea.
|
@mamund Did you have a chance to post the SPEC changes for Suggests? |
For the remote autosearch feature it probably makes sense to send values entered by the user. The href in that case could be a UriTemplate,:
The server could also construct a UriTemplate like this:
How does the client know where to get the value of |
Good catch @dschulten !! Currently we are using this for the search value: "href": "http://localhost:9000/hdiv-ee-bank-services/api/alerts{?filter}" The original post from @robertovelasco was an initial approach but as we implemented it we realized that it MUST be an UriTemplate to be usable. @mamund I forgot to mention that also on the Pull Request, would you mind including it or do you prefer me to do it? Related with the {search} (or {filter}) definition, in our example we use it as a "contains" filter, however I believe this is an implementation matter that should not be part of the SPEC anyway. Trying to answer your question about how the client knows the values in the server, in my opinion there are two approaches, leave it as it is, and assume that it is an implementation detail out of the SPEC, the other option could be to include a valid REL instead of the href Links
Property
I believe it is overcomplicated but it may work. |
@mamund we have been discussing this matter with @olivergierke for the implementation of HAL-FORMS that we are trying to include in Spring HATEOAS. He cleverly pointed out the fact that a small change could make the specification even easier to understand. The idea is to replace the old suggested approach for supplying the value directly, instead of using:
Replace it with:
With this change all the three suggest have the same structure (prompt-field + value-field + (values/embedded/href) I will update the PR accordingly |
I've just updated the PR |
What do you think about using jsonpath expressions in promp-field and value-field? I think that specially in the case of href it would be easier to work with documents that does not follow a predefined structure. |
What we thought about was allowing simple field references and optionally supporting JSON Path expressions in case the field value starts with a |
If @mamund agrees we can include that in the PR also |
Maybe |
Is there anything we (I) can do to help this move forward? I've added support for the latest additions in HAL FORMS to Spring HATEOAS and this here would be the last puzzle piece to move forward with HAL FORMS support in Spring Data REST. The latter is all about exposing default representations for a model connected by hypermedia elements and the suggest/choice feature would be crucial to edit relationships between representations, esp. the flavor using a URI to point to a resource that'd produce the available relationship targets. Except the naming discussion, is there anything obvious that problematic with what Ander and me came up with here? If not, I could prepare a PR to suggest (haha!) some wording for the actual spec. Of course still to be reviewed and debated. I just don't want to start spending time on stuff you think is unlikely to ever make it. To summarize (and slightly extend). What's suggested is: "suggest" : {
"values" : [
{
"firstname" : "…",
"someId" : "…",
"_links" : { "self" : "…" }
}, {
"firstname" : "…",
"someId" : "…",
"_links" : { "self" : "…" }
} ],
"prompt-field" : "firstname",
"value-field" : "someId"
}
Open questions:
Anything else I am missing? |
all: i finally merged the working document on
this may need some grammatical clean-up. and maybe i've missed a few corner cases we discussed here. please check it out and let me know what you think. hoping to get this finalized this week so we can give devs a chance to work with it a bit. thanks to all for the contributions. cheers. |
Great work! Thank you! Currently implementing. If any issues come up, I'm going to start opening individual tickets for them so it's a bit easier to track and/or dismiss issues. This is the typescript type I'm shipping with ketting: https://github.com/evert/hal-types/blob/master/src/hal-forms.ts It has some tweaks from the previous version, but is more accurate. |
looking good! and, yes, open separate tickets as this thread is really unwielding now. (i'll hold onto it until the final commit to spec, tho.) |
Some feedback from the work on support for this in Spring HATEOAS:
|
yes, there is nothing in the current spec that addresses how to "pre-populate" HAL-FORMS properties. the wording
yes, i can see that this would be desireable. AFAICT, both (1) and (2) are about optimizing the programmer's ability to relate resource-state, form-state, list-state in various ways. this can be tricky and i'll work on text for it. might end up as a general guidance note in the spec to cover both (1) and (2) here.
naming & reuse is always a challenge. i'm not going to fight much on what this element is named as long as it doesn't confuse existing implementations or overly constrain future mods. |
Regarding: 2: Also feel the same as @odrotbohm . Having a clearer idea of what the actual use-case here is helpful. In my implementation I'm currently not implementing it, but expanding the templated URI with current form values does sound really cool tbh. Regarding 3: Internally I've also chosen not to call it
I'm trying to pick names for these features that I feel are the 'best general names' for this, and most likely to be applicable in other formats, so I'm diverging internally a lot though. (actions vs forms, fields vs properties, etc)
|
all good feedback. what i suspect is coming is a kind of "common practices" document of how people are using HAL-FORMS. i don't think we can bake too much implementation detail into the spec but we can definitely make sure we support as wide a set of use cases and implemementation patterns as is practical. the more we share how we're using HAL-FORMS, the better the spec can become -- even if the specifics of implementation are not reflected in the spec directly. |
I started implementing this in HAL Explorer. During implementation, I was wondering what the difference is between {
"_templates" : {
"default" : {
...
"properties" : [
{
"name" : "shipping",
"prompt" : "Select Shipping Method",
"value": "UPS",
"options" : {
"selectedValues" : ["FedEx"],
"inline" : ["FedEx","UPS","DHL"]
}
}
]
}
}
|
good to see your feedback. yes, the example you show is a misconfigured message. similar to the problems we can run into w/ other attribute combinations in HAL-FORMS ( SERIALIZING MESSAGES FROM CLIENT TO SERVER SERIALIZING MESSAGE FROM SERVER TO CLIENT |
"preselected" and a pre-existing |
if this is a new record (e.g. it doesn't existing in server storage and the user hasn't typed in anything yet) someone might want to emit a HAL-FORMS with some of the are we thinking about the same thing? |
@mamund this confused me as well when reading the specification for the first time a few days ago. I think what @evert is describing is indeed the same use case as you're thinking of. However, I would find it more intuitive to define pre-filled multi-selects if we allowed the following structure: {
"_templates" : {
"default" : {
...
"properties" : [
{
"name" : "shipping",
"prompt" : "Select Shipping Method",
"type": "dropdown",
"value": ["FedEx", "UPS"],
"options" : {
"inline" : ["FedEx","UPS","DHL"]
}
}
]
}
}
} This requires to allow array content in the |
@carlobeltrame
If we want to make this distinction clear in the API, we would have to support both |
For 1. wouldn't the server just pre-populate the form with values, just like it would for any other non-options property? I.e. if the server wants to prepopulate the destination city, it sets that in the |
I agree with @odrotbohm. In case the client really needs to know the "server state" (e.g. to indicate whether the form field value has been changed), I'd assume that in most cases, that state is also available in some normal HAL endpoint, as normal primitive value:
The same also works if you are not using inlined HAL-FORMS templates. |
@odrotbohm @carlobeltrame |
@mamund – Given that there are still hardly any implementations of the new additions out there, does it make sense to simply scratch |
@odrotbohm @toedter @evert @carlobeltrame and others... i've been quiet here for a couple weeks to allow folks to work through implementations and provide feedback. what is the state of things now? is the feature "done"? are the broken things? missing things? not-needed things? the real question I have here: can we close this issue? -- @mamund |
We're gonna ship support for the current draft in Spring HATEOAS 1.3 RC1 next Tuesday. We don't have support for |
thanks. this is all good. looking forward to continued feedback. i'd be happy if it turns out no-one needs the added |
Yeah, nothing preventing us from putting it back in as optional element later if need arises. |
We are also shipping this, with some caveats:
|
thanks for the update. AFACIT, the difference you have outlined are all local and non-breaking (right?) so no worries there. your feedback on usage once it's your update gets wide use will be helpful, too. |
The one thing that makes us incompatible is the Otherwise, it will be a bit of a pain to model. The general rule (for us) is:
It is currently possible to infer this from The |
understood about your use of do you also support |
Yes, we support them when |
i see. so, for your implementation, support for for example, the service can't just emit |
I missed your reply, apologies.
We could definitely infer that
It's a bit less explicit, but does solve the problem! |
There are some features missing from Hal-forms specification to be a complete hypermedia format.
One is to be able to determine the possible values for a field, for example, a select field with some options.
As pointed in the HAL mail list, there are three cases to support
(https://groups.google.com/d/msg/hal-discuss/bBi-i4FMdxk/8pzDwJFmAgAJ):
This metadata will be added per property in a new 'suggest' element.
Some samples of each case:
Supplying the possible values directly:
Pointing to a data list in the same resource.
And in the same resource:
Provide a Url
And the response of the “http://api.example.org/priorities” call:
In addition I think that the name of the "suggest" property is not very understandable. Maybe "options" name inspired in HTML could be easier to understand from my point of view.
The text was updated successfully, but these errors were encountered: