Grails update html table ajax insert with message - ajax

I'm come from a .net background to grails. I got a form for user to insert, and a html table with the list of records. Once user insert a new record, how do I update the html table with the record and display a message - e.g. company inserted?

Create a domain class for inserting your records, with whatever properties you need. Read Creating domain class and Grails GORM
Once the user submits your form insert the necessary values as a record into this. For getting the entire list of records you can call the list() method on your domain-class. Send the entire list of records to the client side as the response of the action / render as a model. See render. Update your html table using these new records.
For the status part, you may want to do the insert operations in a try-catch block and render a status a message accordingly.

Related

How to secure data in html select object filled with Ajax from MVC database

sorry for my english
I am filling the select element with values ajax from the database. Then I want to verify that the data that changed when the user posted the form as a result of changing the value values of the select object through the browser is really the data I filled.
How can I solve this with a general coding in infrastructure?
Instead of going to the database and checking each filled data one by one, I want to hold the data I filled in the select tag and check the verification with this data in the post operation.
mvc fill select changed value example

get last record ID after insert Joomla 3 component

I am writing a Joomla 3 component and new to the Joomla framework.
I need to insert data into two tables.
the logic follows
insert form data into table after submit
retrieve data for next insert ( i can do this and i have the data array )
insert data from array into second table with the PK of the first insert from step 1.These tables are related by 1-M
return the user back to where they came from with success.
I think i have to override the save method in my model to do this but i don't understand how to get the pk of the first save to use with the 2nd
Due to my lack of understanding I am not sure of best practice in this situation.
after reading there is a postSaveHook() method but I am do not understand how to access the data as it returns void
If i copy the Joomla parent save Method and override in the model it will return Boolean therefore i don't no how to access the last PK from the first insert / save.
thanks in advance for any advice.

Magento Custom Form in create order page

I want to add custom form in create order page in magento admin side.As per my client request i was trying to create measurements form and wanna store data.I am new to magento.Please help me.Attached image for ref.
Already posted same question in Magento Stack Exchange My Question
I created block in layout/sales.xml file and created customform.phtml.Now i'm able to display custom form.Now i want to store data along with other data in this page.
You should add a table (with order id as foreign key) or a new text field to order sales_flat_order table.
After that, you are able to catch this event: sales_order_save_after
Inside this function, you can save data to the custom table or custom field you added.
good luck.

joomla dynamic drop down on registration form

I have two drop down list on my registration page of sql type. they both fetch data from database. but my problem is that in second drop down list , i want specific data as per the option selected in dropdown list 1. how to do it?
thank you very much
There are two possibilities(well theoretically endless)..
1) You send the whole data on pageload and then filter it using javascript based on the first selection.
2) Use the ajax technique, where you send the ajax handler the selected value and then the handler queries the database and sends the relative data which you append on the second select in the runtime.
Note:- for larger tables the firstone is NOT Recommended.

JSP page to immediately display whenever a new row is added in table?

I have oracle dbTable letssay testDbTable having column columnA and columnB.Whenever a new row is added in database table,it should display content of that row on JSP page in following manner.
columnA(value):----- and then columnB(value):........
lestsay after some time a new row is added in testDbTable.
then output should be in two line. Added new row in testDbTable should be aove on previous row that was displayed earlier on JSP page.
columnA(value):----- and then columnB(value):........
columnA(value):----- and then columnB(value):........
But such action should be at same time whenever a new row is added.
The simplest way i could think of that check on database again and again for some predefined lenth of time,but this solution seems to be wasteful and suboptimal to me, so i was wondering is there a better way.
i think there should be a trigger on table,when a new row is added in db then trigger should be fired and display row content on JSP page. I know "how to create trigger on table" but after that i am blank,how will i display just added row on JSP. After trigger on db table how will i approach? Can Ajax solve my problem like auto refresh or watch on db table or sothing else?
is there anyway i can listen to a trigger on my database from a .jsp script and force my client page to be refreshed ? Can you provide me any example link related to ajax,oracle dbtriggers and JSP?
In this case you should try reverse ajax technology like Comet.

Resources