What is the best way to persist data between pages within admin on rest - admin-on-rest

We have a simple CRUD admin on rest project and with one of our objects, we would like to "Save and create another" with some prefilled in form fields. What is the best way to persist data within AOR?
Right now, I have a solution working using localStorage, but it is not awesome. I have to refresh the 2nd form to have the data prepopulated.
We are thinking about modifying the URL params to include the prefilled form fields, but this seems like a lot of work for something that should be pretty straightforward, particularly within an admin framework.
Thank you in advance!!

The Create component accepts a record prop to setup initial values of the form. This values is merged with the values of the defaultValue prop (can be a function) and values from the admin.record state in redux.
So in your situation the defaultValue prop would allow you to generate the data from the params prop of redux router.

Related

Populate Wicket table with Ajax

Is it possible to have 1 input text field that accepts characters from the user, and as the user types, queries to a webservice are launched, and to update the contents of another component dynamicaly with the results of the webservice (which would be a table below the input text)?
If you prefer to use Wicket form controls and Data Table component then you need to make the call to the REST service in your impl of IDataProvider.
Otherwise, as I explained to you earlier today in your other SO post you can do this directly in JS without Wicket. It is a matter of taste and skills.

Spring MVC update field based on calculation

I have page with spring form fields.
They're bind using command.
Couple of fields in form need to be update based on calculation from other fields.
Those fields can be modified by user.
How can I do that?
I think about trigger java calculation in model using onchanged in web page. But I don't know how access methods from model and how read fields from page.
I notice, that field are update by setter when page is submit. This is too late if I want calculate 'live' when depending fields are changing.
If you need these calculations to be done on server (java model)... I suggest to use input's onChange event as you said, send values with AJAX to server and calculate there, returning the result to client again for update UI in real-time.
With this approach, you will get the 'live thing' you are wondering for.

MVC3 - what is the best practice to validate the old data and new data when submitting a form

I am using mvc3 for my web app.
When an user edit an existing form, make a few changes and save it.
what is the best practice to check which field in the form has been modified.
Regards,
Bubblegum.
Since we're not talking data access - upon postback, compare it to your object in your database. This is somewhat of an open question because it depends what data access you are using and what models you are using. Entity framework Entities can track their modified state so you may be able to use
TryUpdateModel(yourInstanceLoadedFromYourDatabase)
and check the status of each field. That 'may' work, otherwise you are comparing each field. However why do you need to know specifically which field changed? Save the entire object back to the database (or simply merge with the values from the page using the same TryUpdateModel above)

ASP.NET MVC 3 how to implement many to many relationship in Create View

I have quite a complex class that has three one-to-many relationships and two many-to-many relationships with other classes. What I would like to do is to enable the user to fill all the details one by one - in one step or even better in multiple steps (wizard).
My class is called PeriodicTask - user has to select one Server object (which represents SQL Server instance ) and depending on the selection I need to present the user with the ability to select which databases he wants to use ( the best option would be to use checkboxes). I don't really know how to achieve this.
I would start with creating an action that returns JSON with databases for the selected server. It'll be invoked by jQuery. So far so good, but what to do then?
Should I add <input type="checkbox"> to the form for every database or maybe create another form and post to some other action? How to parse that when the form is submitted? Can I split it somehow into smaller steps ? HTTP is stateless so I somehow need to pass or remember the data that was previously submitted - how?
PS> I'm using Entity Framework here, so part of the class hierarchy is as follows:
You could do it like this:
User selects server instance from
dropdownlist.
After selection dropdownlist fires "change "event, handler of
which loads databases list to form using ajax (your action can provide JSON or html with checkboxes)
User selects checkboxes and presses
submit button
On submit you collect
checked item and post to action
using javascript
I would look at creating helpers for each of the options that would be self contained, they could maintain the state themselves.
Another cool option would be to create a tree view, where the root level is your server and next level is database. Load the data into a ViewModel so that it can be used as the data source for a tree view. It seems like a nice interface for what you have.
Believe it or not the Microsoft site is a great place to start when learning MVC
http://www.asp.net/mvc

MS CRM Save + Copy as new (Custom Entity)

I have a custom entity in Microsoft CRM (4.0). The user has to input records however usually they have a batch of 20+ records that are almost the same apart from 2 or 3 fields which need changing. I know I need to write some custom code to enable this functionally. However can anyone recommend any methods to do this.
Ideally there should be a button that will save and create a copy as a new entity.
My Current way of thinking is to pass all the details as part of the URL and use javascript to strip them out on the page load event. Any ideas welcome.
Thanks
Luke
I found the answer here:
http://mscrm4ever.blogspot.com/2008/06/cloning-entity-using-javascript.html
I've used it and it appears to work well.
Since there are numerous fields, but only certain fields values are different, then i am thinking to set the default value to all the fields, so that users just need to alter those values when needed.
In my approach, i will hook a javascript function on load of the form data entry screen and use XmlHttp approach/Ajax approach to hook to the custom web service to pull/retrieve the default values of each fields. Or you can set those values at the javascript function itself, but the drawback of this, it's difficult to customize later. So i will choose the approach to hook to the custom web service and retrieve those value from some application parameter entity.
Your idea of providing a "clone" button is also a great idea, which means that it will duplicate all the attributes of the previous record, into a new record, so that it will save time for data entry person to customize the different value
EDIT
Since you would enter records in batch mode, how about customizing .ASPX screen to enter records. By customizing through .ASPX screen, you can use a tab , so that users can browse through tabs, to customize the value/attribute of each record.
There will be a "save" button as well as "clone" button to clone some common attribute or value.
I would create a custom web service that would accept the entity type and the ID of the record I'm cloning. Your "Save and Clone" button would call the service, and the service would handle the details of retrieving the current record and deciding which fields to set on the new record. The service creates the record, and sends the Guid of the record back to your button, which then opens up the newly created record.
This way, you avoid the messiness of setting/getting values in JavaScript and tying which fields to set/retrieve directly to your OnLoads, as well as avoiding the possibility of query string that's too long.
The service could easily be sufficiently generalized so that all you'd have to do is add your button to any entity, and it would work, assuming you'd set up your service to handle that particular entity.
One possible downside is that since the clone record button would actually create the record, the user would be forced to delete the cloned record if they decided they didn't want to clone the record after all.

Resources