Spring MVC update field based on calculation - spring

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.

Related

Validation running on all rows when tabbing Oracle ADF

I want a validation to fire after hitting tab on a field. The thing is every time I click on the empty field it runs the validation to all rows. Which causes errors because the other existing rows in the table aren't in the scope of the validation. I am using a back bean function to and can see the validation is called everytime I hit the empty field. I think this has to do with autosubmit being on but how else can I validate on a tab?
I don't know that this will answer your q's but might be a start:
http://www.slideshare.net/stevendavelaar/18-invaluable-lessons-about-adfjsf-interaction
https://docs.oracle.com/cd/E15586_01/web.1111/b31973/af_validate.htm
https://rohanwalia.blogspot.com/2013/10/client-side-validation-in-adf-faces.html
https://www.jobinesh.com/2009/08/how-to-skip-validation.html
Also, if you're doing ADF work definitely get Jobinesh's book as it covers many things in depth: https://www.barnesandnoble.com/w/oracle-adf-real-world-developers-guide-jobinesh-purushothaman/1111982100
Also consider ADF Cookbook.

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.

Check if Associated View is blank in Dynamic CRM Online

In CRM Online on a customer form is there anyway that you can check if the Associated View for Assets is blank? And if its blank change a field value based on it.
Using JavaScript, 2 ways:
The associated grid is showing records related to your primary record. You can perform the same query the grid is doing using REST which will tell you if there are any records. You can then count the records, and change the field value as required. This approach is better if there are records in the database but which aren't shown in the view for some reason, e.g. view filters.
Access the Grid objects data using getRows(). As above you can then count the records, and change the field value as required. The downside of this is I believe those methods only give you access to the records shown on the form (and not any hidden by filters but still in the database) - but I don't think that that will be a problem here.
Worth bearing in mind that this approach only works client side, e.g. someone has to be actually looking at the form.
If you need to cover the a non-client side approach, e.g. workflows creating records, then you should probably look at plugin development so the changes can be performed server side.
As a side if you just want a simple count shown on form you then you should probably look at Calculated Fields and in particular Rollup fields. You might also be able to run further client side JavaScript from the count.

Can we prepopulate the webform fields with values in webforms for marketers?

We have a requirement to pre-populate the Contact Form with user information on load if the user is a logged in user. So that, user need not fill his information using the webform.
Is there any way to do this using webforms for marketers?
Data is coming from a service api in json format. Need to figure out a way to bind it to fields either in server side or in client side.
Sitecore Version 7.1 140117 WFFM Version "Web Forms for Marketers
2.4.0 rev. 140117"
Have a look at Sitecore - Webforms For Marketers Form - Use ReadQueryString Option. Basically, there is a checkbox, ReadQueryString, in presentation details that gives you the option to fill in the default values from the query string. If checked, you use the item names of the fields (not the display name or title) as keys and the values you want to set the fields to as the values in key-value pair in the querystring.
Create a new rule based on use default value from user profile [fieldname] field and amend it to pick up the value from your service API.
This will be your best way and simplest option in my opinion.
I use this same approach prepopulating ucommerce data from its API.
Create custom field and then you can pre-populate values as per your need.
Like if you want to populate any value in Single line text field the create custom field for this and then reflect forms dll and copy code then update code as per your need.
Please check https://sitecoretweaks.wordpress.com/2015/02/20/custom-field-type-for-sitecore-web-form-for-marketers/ blog post for more details.

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)

Resources