I’d like to create an input output text field; the field (input text field) is initially populated with the data coming from a service but it must offer the user the possibility to modify those data and submit the new data.
I’ve tried using a managed bean variable, binded to the service output and setting the value property of the input field to the same variable but this overwrite the variabl’es value.
I even tried with in-place input but it doesn’t work.
The last time i implemented this use case, this is what i did:
I had two services: one to Get the data which i call GET, the second one to set the data which i call SET.
The GET service had some data it returned, which i’ll call GET-DATA. The SET service had some data that it took which i’ll call SET-DATA. Both GET-DATA and SET-DATA was the same data structure, they just originated from different services.
Next, i’d drag and drop the GET service onto the canvas on to the page to display the data. I’d modify the Output only controls to be Input as needed, but i wouldn’t change any of the bindings. At this point, i’m only working with GET-DATA.
(At this point, i’m going to skip when the GET service is refreshed. I’ll assume it is auto-refreshed).
Now that the user has modified the GET-DATA, we want to allow the user to submit that data. I would add an Async-Command Button (it doesn’t really matter what type of Command control though) to the form and implement it with DataFlow. (You can use java if you’d prefer).
In the DataFlow, i would assign all of the SET-DATA to be equal to the current GET-DATA. This takes all of the modifications that the user has made and prepares them to be sent to the SET service. The last step of the DataFlow is to refresh the SET service.