Spring : Updating table entry - spring

I am new to Web applications. I am implementing a simple one that enables to show all the entries of a table (i am using Spring + Hibernate). I added a column that contains a link enabling the update of a table entry (in reality, juste one column can be updated the other ones shouldn't be changed).
I would like that when i click on this update link, a form of update should be displayed
and this form is initialised with the values of the columns of the table entry.
for example: if the entry is :
USER1 | 55 | 190cm | 80kg | "update link"
only the weight column can be updated, so the form of update so be initialised with:
name : USER1 (cannot be changed)
age : 55 (cannot be changed)
height : 190cm (cannot be changed)
weight : 80kg ( THE ONLY COLUMN THAT CAN BE CHANGED)
How can i pass the values from the "display.jsp" page to the "update.jsp" page?
should i pass through the controller or froma jsp to jsp directly?
Thanks,

Each controller must be responsible for loading appropriate data and passing them to corresponding view. The only info that you need to pass from one page to another is unique identifier of choosen line. Consider example where you want to change a record with unique identifier = 758. Normally unique identifier will be passed trough URL param:
http://example.com/update_controller_address?id=758

Related

Is it possible to store different id (of same type) inside one row?

I'm using laravel 8. In my database, I've this :
In my form, I have at least 2 or more checkbox of type theme_id (which is a foreign key inside my table). I need to put in my database the ones which are checked. Is it possible for me to store several id inside theme_id like this 1,4,8 ?
I did not find any documentation about this.
Cordially

Spring mvc form submit not binding/updating the children objects [of list type] properly

I have a data model that is something like this:
I have one parent entity A and it has one children of list type B. In order to display the data on JSP page, i am passing the object of entity A as model attribute..
I am able to display all the properties of entity A by binding the spring PATH attribute of the field. I have one section in JSP in which I am displaying the table of property (of type entity B) as it contains the multiple elements in the list of type B by iterating the elements using jstl for loop. Till this point everything is working as expected.
We have one functionality on JSP to add the new rows in the table of property type B. I have written one JS method to add the new row in table and also increment the index of the spring path attribute by 1. i.e. if the existing row path points to propertyB[0].name, then the newly added row's path will point to propertyB[1].name.
When I add a new row in the table and also update the existing row in the table. Upon form submission, I am getting the updated value of existing row in the controller but I don't get the newly added row as new element in controller.
What I need to do to get the newly added element in the object.
get the id from A.
get the data from the newly added B
send to controller by ajax
in the controller you can update database;
return an object in json in ajax;
judge the update is right or wrong;
if right use jquery to show the newly B ,if error,alert some something

Laravel validate form input with database

I have a dialog for checking in a visitor. On submit I would like to check the database if values exists. I'm having some trouble building up the validator.
There are two tables.
table: visitor
- id
- name
- signed_agreement
- ...
table: visit_type
- id
- name
- require_agreement
While submitting the form I send two values; the visitor id and visit_type id.
If the visit_type require_agreement column is equal to 1, the signed_agreement of the visitor should also be 1. If not, the validation should fail.
Any suggestions?
You can use exists:table,column to check if the value exists on db or not. You must add different validations for each table & field pair.

Servicenow - Service Catalog Reference Field - Insert different column than the display value

Let me describe my problem:
I have a table for all my IT-Services. I reference to this table more than once, for different purposes. Most of the time I need to reference to the name of the service. That's why I keep the name as displayed value.
One Column of that table is a service_id (custom field) which is for example "Service_004". Now in a catalog request Item the User has to fill in the service_id in a reference field.
But since I have the name as displayed value, and I need it in other forms, I am unable to reference to the service_id.
Using the variable attributes field I managed to let the service be found using the autocomplete function. But in the reference field I still get the servicename. I know that I can change the display value in the dictionary, but this breaks other functions. So what I need is to change the display value just for one reference field.
Also I tried to create a new table called IT-Services2 with reference to my table IT-Services. Then I switched the display to true in the new table for my service_id, but this will even change it in the parent table.
Perhaps an onChange client script utilizing g_form.setLabelOf() ?
http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#setLabelOf
Maybe I'm not fully understanding your question...
I ran into this issue before, what you can do is create select box variable and use an on load client script to populate the list with the service_id(s) from the table you are referencing.
I would write a script include to pull the data from the table and call it from the client script via GlideAjax.

Jomsocial - How to add an extra field on the first page of Jomoscial registration

I am struggling to do a hack in the default Jomsocial Registration.Problem is that, if you see the default jomsocial registration page it has all the fields that are there in default core joomla registration page.i.e Name,Username,E-mail,Password,Verify Password.
But I want to add an extra-field on this jomsocial page.Right now if i add a extra field using custom profile then user has to click next and go to next page which is long process and giving high bounce rate on my user registration.
So can you please advice me on the same and one more thing is it like if say we add a field in Joomla default registration page it will automatically come to jomsocial first page..
Will be thankful,if someone can help me to solve this problem.
You can add custom registration field on the first page by following the process (works with joomla 2.5) :
Step 1 : You have to add the field so that it appears on the first page (front end), for that go to components\com_community\templates\default\register.index.php
Now just add the field as other fields are there, for example(FIELD is taken as field name to be added)
See example here : Click Here!
you may copy and paste other field details and then edit for your own, the label tag shows how the label will appear at the front end, the input field shows the input field, you can adjust the size, but should not change the id, name (as would be required while collecting the data) and the value (other then replacing the previous field name with the new field name where ever it appears!), class can be edited as required, like removing 'required' will make the field optional to be filled, validate-FIELD is used if you want to validate the field using some script for the values entered, span is for displaying the error msg... now when you have added the field so that it appears in front page, you will have to do some work so that the data is actually taken to the database when the form is submitted! So we go for ---
Step 2 : when the form is submitted, the data is not stored in prefix_users table, but an object is created which stores the temporary information and then it is stored in com_community\models\register.php , now to change the object and add one more field so that the object contains the value of our field also, we have to add one line in it, you will see code like
$obj = new stdClass();
$obj->name = $data['jsname'];
$obj->firstname = isset( $data['jsfirstname'] ) ? $data['jsfirstname'] : '';
$obj->lastname = isset( $data['jslastname'] ) ? $data['jslastname'] : '';
$obj->token = $token;
$obj->username = $data['jsusername'];
$obj->FIELD = $data['jsFIELD'];
$obj->email = $data['jsemail'];
$obj->password = $data['jspassword'];
$obj->created = $nowDate;
$obj->ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ?
in the above code, in the 7th line i have added my field so that the object also stores our field when the form is submitted, now we must add one field in the table where this object is actually stored for a moment, that table is prefix_community_register
The table is like -
1 id int(10)
2 token varchar(200)
3 name varchar(255)
4 firstname varchar(180)
5 lastname varchar(180)
6 username varchar(150)
7 email varchar(100)
8 password varchar(100)
9 created datetime
10 ip varchar(25)
11 FIELD int(11)
11th field of the table is the field we are adding, it must be of same name as field inside the object (eg. if the object has $obj->age , the name of the field in table must be 'age' too!), so now finally we need to store the same data permanently in the prefix_users table, so create a field in the table with the same name and attributes, when the registration is complete, the value will be stored in the users table too, then you can use that field where ever you want ;)
Go to Administrator--> component --> Jom social--> Custom profile --> New Field .
Here you can easily add your New field..!!
I think it will be help you..!!
I actually use Jom Social and Joomla. I have used them for quite sometime and here is the link to the answer to this question.
I am not sure if it has changed in 3.0 JomSocial but this should help.
Jomsocial Custom Profile - Display email used on first page of registration onto the second page of registration
Also keep in mind you can always create your own registration page and then allow users to fill in the secondary profile information from their edit profile page. Just redirect to edit-profile once logged in.
A good component to use to build custom forms and such is http://fabrikar.com.
Hope this information helps

Resources