How to find the modified ActionForm bean in struts - struts

I have a requirement in struts 1.2 framework where i have 50 to 60 fields in my form in which i have to update only 3 Fields(which are changed by the user) so when i submit the form,only these 3 Fields needs to be updated in the database.
How can i identify the 3 changed/modified fields out of 50 fields in the struts ActionForm.
Your suggestions are very mush appreciated.

There's no way to do this since when you submit the form you're submitting all the fields (except checkboxes, sometime).
You could use javascript and ajax to just post the values you want to change. Set an event handler on your fields to detect that the user changed them and post just your changed fields. The problem with this is that you can only use javascript to submit the 'form' if you go that route.
Personally what I would do is create a javabean that you can populate from your form that just contains the 3 fields that you're checking if they changed or not. Grab the current data from the db (or you can use a session attribute if you don't want to query again) and populate another instance of your javabean with that data. Compare the two beans to see if the fields are equal. Process the rest of the form based on the equality of the beans you're comparing.
Or as long as you're using an actionform to populate the fields to begin with, compare the actionform that the user submitted with another one populated with fresh data to determine what you actually need to persist.

Related

How do I store data in an SQL database if the database columns can be different?

I'm creating an ASP.NET web application which allows users to digitize paper forms. The user will import their own forms which will be converted into HTML with placeholders inserted to accept values from an input form.
Using the fields on this imported paper form, the website will create an input form based on what information is required. "Templates" can also be created for a specific form which allows a user to auto-fill any data that doesn't normally change with each form fill. A user can also save a form they haven't finished for completing/reviewing later.
My question is: how do I store this data? I can't really use a traditional database table because Form X could look nothing like Form Y and require completely different data. I have a SQL database to store the data in (I need this for other aspects of the site too), but I can't simply store all form data in one table or even have separate tables for each form as this will be impractical on a larger scale.
My initial thoughts were using JSON but I have absolutely no idea where to start with this. Can I put JSON data into a regular SQL database column? Can this be used to generate code to build a web form to allow a user to easily fill out their forms using any device (as per my design requirements)?
I think your problem would be very well served using a document DB like mongoDB or Arangodb. Reality nowadays is that applications can , and sometimes should, use more than one DB.
Having said that, if I had to use a relational DB, I would convert your forms into 3 tables. The first top level form would just store something like:
form name ,
form id ,
etc...
The second table would capture the form fields and would look be something like:
FormID
field Id
field name
fiel type (int, varchar, etc...)
sort no.
etc ...
The third table would capture the information entered by the user:
user id
form id
field id
value
creation date time
last modification date time
etc...
Note that by storing the fields in rows instead of columns, it does not matter that you have different types of forms.
I should mention that the above table definitions are not meant to be complete by any means, they are there to give you an idea on how to get started.
Finally, note that many relational DB allow you to store JSON nowadays directly in the DB as you suggested, but that may not be a very good option depending on which DB you are using. Here is an example of storing JSON in mysql just for your reference.

VBA access and forms

I created a database in Access and there are some type of records in some tables that requires a particular inserting, so I decided to use VBA to handle this.
The problem is that if i create a form with some controls which i want to refer and use their values as criteria for queries, the form is still a way to insert data. So the query works but the data i inserted are added directly from the form too, creating duplicates.
The question is, is there a way to create a form that has controls only for text input but does nothing to record , leaving inserting, deleting , updating all to queries in VBA?
I tried to put "no" on propriety "add records" in the form but it gets totally blank with no controls.
Your form must be unbound, i.e. its RecordSource must be empty.
Your form can be bound or not bound to a table / query.
This means that the controls on your form may be bound to a field of that table / query.
But you can also have controls in the same form which are not bound.
Example:
You can make a form in which the body has a list view of the records of the table. In this section the controls would be bound to a field.
In the header of the table instead you may have controls that are not bound and that could be used either to filter the records shown or to add new records. You may want to add records this way rather than let users insert data directly in order to add checks or do any other kind of processing before actually adding the data in a new record.

How to handle search for custom fields in form for FROM and TO fields?

I have just started implementing search module in a project, where I have a form with fixed fields consisting of combo box, text box, radio button etc (around 200 fields in multiple tabs), and later client should be able to add extra fields too. Once user fills the fields which he wants to search, that search criteria also he should be able to save. For all these reasons, for each field I am associating metadata in the following format.
"EntityName.attributeName": attributeValue
Once the user fills the form fields to search, I will validate form data and and only non empty fields metadata I am sending to server in JSON format. Everything is fine till now. But I am facing an issues now.
Using the metadata of each field I will create a new criteria for each field. but if there are fields where one field metadata depends on other field metadata I am struck.
In the form I have few special category fields in following format : for example DOB,
FROM DATE (meta data: entity1.dob)
TO DATE (meta data: entity1.dob)
both fields belongs to same entity and same column only field name in the UI is different
Like this I have around 20 fields which asks for FROM and TO to query the range (it need not be on date, for example no of bed rooms..it can be on integer, string etc)
My query formation should be in the following way depending on user search criteria. If user entered only FROM field of number of bed rooms then I have to query using EQUAL to operator in sql and if both mentioned then MORETHANEQUAL to for FROM field and LESSTHANEQUAL to for to field. So how I can handle this special case ?
like if he entered number of fields as 4 in TO field of number of bed rooms, then I have to query for houses having number of bed rooms equal to 4. but if in FROM he entered 3 and in To if he entered 7 then I have to query for houses having greater than or equal to 3 bed rooms and less than or equal to 7 bed rooms.
Since I have same metadata for these category fields also I am unable to proceed, to achieve this, what kind of metadata I need to prepare ?
How I can generalize this process to handle all the cases ?
my technology stack: ExtJs, Eclipse Link, spring.
and what are the best practices to follow to support custom fields adding feature in Forms in enterprise applications ?
Off of the top of my head, I would create wizards for these particular cases. So for example, have a custom wizard that allows the user to define a "from" field, a "to" field, and then the comparison operator in one action. This wizard could also be responsible for adding custom properties to the generated fields that could be used by your validation routine. So based on the combo of from, to, and operator, you could create a flexible validation mechanism for ensuring that correct values are entered, ranges are correct, whatever.
You might consider this "wizard" approach for all custom fields, in fact. I could see you predefining all the possible custom field types that could be used and create classes that can be used for those. The classes could be responsible not only for the field creation, but also for providing any custom validation, pre-submit transformation, etc. This approach would make adding new custom field types incredibly simple since all you'd have to do is follow the same implementation as the others that already exist, extend an existing one, etc.

Infopath 2010 - Create a repeating block from each item in an array on form load

Please forgive me if I don't explain this well. I'm new to Infopath. Here goes!
Overall Goal: Create an infopath form that will generate an email, eliminating certain 'human error' problems that we've been having.
Problem: Automatically creating a new repeating block for each item in the list/array.
The list would be something like:
PROPERTY NAME = Prop 1, Prop 2, Prop 3, etc.
Below is the entire block of data that I want to repeat.
*PROPERTY NAME* – OPEN or CLOSED
Hours – XX:XX AM ET – XX:XX PM ET
No incidents open
IMxxxxxx - Incident details | Status: Red
This entire block needs to be repeated for each property we own. Now, while I know that I could create multiple blocks for each property manually, that makes creation and maintenance of the form time consuming . Ideally, I'd like the form to read the property's from a list or array, and insert the name into each new block when the form loads up. The rest of the info would be filled out by the user of the form. This way, if we ever add or change a property, I or someone else can easily update the form by simply adding the new item to the list/array.
I have been Google'ing this for hours today and I think my problem with search results boils down to my lack of knowledge of the proper terminology.
Does anyone have any ideas?
Create a secondary data connection to the source list (where does it live, BTW? SharePoint? SQL?) Drag the data node for the secondary data connection onto the canvas as a repeating section with controls. Remove controls you don't want to see and arrange the others to your liking.
Upon form load query the secondary data source. The repeating section will then be populated with the items returned by the query. This will only read the items, though.
If you want to edit the items, then you need a repeating group in your main data source. After querying the secondary data connection, you need to copy the data from the secondary to the main data source. Edits can be done in the main schema, and you will need a submit data connection to write back the changes.
This is not out of the box InfoPath functionality but it can be done with code or with 3rd party tools like Qdabra Software's qRules.

InfoPath 2010 NaN

I have been trying to update a text field in a form that will automatically generate a new number in a read only state when a user fills out the form. When the user completes the form and selects the submit button, the form will be attached to SharePoint List and the following user will open the form and the number field will be the number +1. I have used 'count(mynumber)' and the field returns 1, but when I close the form and re-open it, the field still displays 1 and never increases. When I use 'count(mynumber) + 1' the field returns 2 and also never updates. Finally, I used 'max(mynumber) +1' and it returns NaN. I have come to the conclusion that there is an array here, but don't know what I need to do, to fix this.
I have informed my manager of 'InfoPath 2010 Cookbook' so hopefully this will help, but I also took a gander as this following link, which was not easy to follow as I believe its for 2007 instead of 2010.
http://claytoncobb.wordpress.com/2009/06/15/auto-numbering-infopath-forms/
I am using SP 2010.
So, here is the simple approach to the simple request:
•Just like in any database, every item in every list and library in SharePoint has a unique ID. This ID is stored in the ID field, which is available for viewing in any list or library. Go to your list, modify the view, and check the box next to the ID field so you can see what I mean. This ID is 100% guaranteed to be unique and is never duplicated.
•Since you already have purchase order numbers, you can't use the IDs by themselves, however, you can use them to drive your auto-generated Service Order numbers
•The easy method for doing this is to utilize your SO field, which is now a Number field, and determine the differential between the next ID in the list and the next Service Order number that needs to be created.
•Then, create a simple workflow in SharePoint Designer 2010 that ONLY runs on the creation of a new item (only runs once per item/form), and set it to add the differential to the current item's ID (Something like Do Calculation: ID + 1200) . Next, use Set Field in Current Item to set your SO field to the variable created by the Do Calculation step
From then on, you will always have a GUARANTEED unique, auto-incremented SO # for each form, and you should make this field read-only inside the form so that users can only view it and not edit it.
--Clayton Cobb