I am developing a web application using JSP & Servlet (IDE: Eclipse, Database: Oracle10). I am using jqGrid to display records in tabular format.
code snippet:
{name:'CITY',index:'CITY', width:70,editable:true,edittype:"select",editoptions: {dataUrl: 'ProfileServ?action=comboCity', dataEvents: [{ type: 'change', fn: function(e) {alert(this.value);city= this.value;}}],}},
{name:'PIN',index:'PIN', width:200,sortable:false,editable:true, edittype:"select",editoptions: {dataUrl: 'ProfileServ?action=comboPin'}},
I want to change values of PIN according to the value selected in CITY. I have used dataEvents and type: 'change' to get the selected value of CITY. I am successfully getting the selected value of CITY.
My question is that how should I update the values of PIN when value of CITY is changed?
Unfortunately there is no easy way to implement dependent selects. One have to update the whole <select> of dependent select manually inside of change callback (update selects of PIN in your case). The only which I can suggest you is examining the code of the demo from the answer. It is not exactly what you need because it don't use dataUrl, but it shows what should be done.
Related
i have a db query and i would want to return the results in tabular format (one row after another )multiple rows in a tsendmail component and display in the email:
i tried using tbufferouput/input,but it only returns the last record since tjavarow ovewrites on each latest run with the new value but i would want to get all the results at once in a single email ,in this case 9 rows at once
You could use a tJavaRow before your tSendMail to cumulate results into a single variable.
context.cumulateResult=context.cumulateResult+input_row.row1+" "+input_row.row2 etc
Then in tSendMail you can just set the content as context.cumulateResult (you can also use a global Variable instead of context variable).
I have working Spring REST app with client side pagination, default by DataTables and everything works. Now i need to change it to server-side pagination i have problem, because have no idea how to get information from DataTables what page number client want to see. I can't find anything usefull in DT manual.
When you say Datatable I assume you are talking about DataTables jQuery plugin.
To activate serverside pagination you need to pass
"serverSide": true,
like this:
$('#example').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "/your_url"
});
Doing the above will activate your server-side pagination. But you need to do few changes on the server-side too. Let's see them step by step.
1. What happens when you mark serverSide as true
DataTables plugin adds custom parameters to the AJAX call with information like
order: asc
start: 20
length: 10
// and many more.
You can inspect this demo link and see the parameters passed in request when you click the next page button.
2. Similarly, DataTables plugin expects some fields in response in order to preserve pagination logic.
"draw": 3, // unique ID
"recordsTotal": 57, // total number of records
"recordsFiltered": 57 // total number of filtered records
You can inspect this demo link and see response data this time.
3. Now changes are on serverside in your API
You need to add these parameters as queryParam for GET and attr in POST call in your controller API:
order: asc
start: 20
length: 10
4. Service Layer Changes - DB query
In-Service Layer where you get details from a database.
You need to get the total number of records and in search query pass a LIMIT clause LIMIT 10, 10 in case of MySQL.
E.g.:
SELECT * FROM User LIMIT 20,10;
Use start and length to calculate the next set of records.
It can be trickier but if you understand and implement properly it's fun.
Read more in detail here which also contains code and live demo.
Please see the sample about DataTables server-side processing:
https://datatables.net/examples/server_side/simple.html
After change page, you can capture the request to server as following format:
https://.../server_processing.php?draw=3&columns...&order=0&dir=asc&start=20&length=10&search%5Bvalue%5D=&search%5Bregex%5D=false&_=1534436781912
That means DataTable requests page number 3 (draw=3), order by first column ascending, ....
At server side (REST), you can get page number by (for example) request.getParameter("draw")
I am using RESTFUL webservices using Spring framework.Some information is displayed on the user interface using the data returned by webservices. There is a webservice, which gets the usernames and their roles from the database. For a particular user , I would like to have all the webservices display data in the form of ####,#### for first name,lastname ; ##/##/#### for date of birth etc. Since I am using JDBC to connect to the database, here's what I was thinking of doing:
Should I consider passing an additional parameter (maybe sending a value 0 or 1 ; 0 for all other users and 1 for user for which I want to hide the information) to each and every GET webservice so that when it comes to getting data from the database in the JDBC code part,I could check whether the flag is set to 1 or 0 and based on this, I could do something like this in the JDBC code :
// Code for a case when flag is set to `0`. Hence retrieving information from the database.
while(rs.next()) {
EmployeeList empList = new EmployeeList();
empList.setEmpId(empId);
empList.setEmployeeName(rs.getString("name"));
employeeList.add(empList);
}
// Code for a case when flag is set to `1`. Hence hiding information and not retrieving information from the database.
while(rs.next()) {
EmployeeList empList = new EmployeeList();
empList.setEmpId(empId);
empList.setEmployeeName("####,######");
employeeList.add(empList);
}
I am wondering, if this is an appropriate way to achieve my task or is there some other way around?
Edit:More clarifications on my requirements:
I am using jqxWidget in the UI to display the information I am getting from a RESTFUL webservice in JSON format. For example, let's consider this example and the screenshot for better understanding of my requirement:
1) Let's say I am getting all the information from the JSON response which I am populating in the jQXWidget as shown in the screenshot above.
2) In the above widget, I would like to hide say for example, First Name, Last Name and Quantity like the following:
First Name = XXXXX
Last Name = XXXXX
Quantity = ####
In my application, if a user clicks on a particular row , a new page is displayed with some additional information. After click, new sets of web services are called and those web services takes First Name, Last Name and Quantity as input parameters. My concern is that, if I somehow replace the First Name with XXXXX, Last Name with XXXXX and Quantity with #### using any approach, when a user clicks on any of the row of the widget, the next set of web services
are going to get XXXX and #### as input and eventually will fail. Please correct me if my understanding until this point is not correct.
Thanks
I am using Spring 4.2.5 version.
This depends on what sort of information hiding you want to achieve. Typically you shouldn't do this manually.
You can use, for example, role-based authorization. Exact details depends on the web-service framework you are using.
For spring MVC, you can use something similar to this:
Custom authorization in Spring MVC
I had created one search page using custom viewcriteria with five parameters.In my search page working perfect.I have one doubt,we are entering the some parameters in the search page to get the details from one table, Here i need that values which we are entered in that boxes for using that values into a one java class.
How get those values?
Maybe ,This link can help you.you should glance
http://www.awasthiashish.com/2013/07/implementing-custom-search-form-in-adf.html
You can read the search value from a custom BC method (either on AM or VO impl level):
ViewCriteriaImpl applyVC =
(ViewCriteriaImpl)myViewObject.getViewCriteria("MyViewCriteriaName")
while(applyVC.hasNext) { Row vcrow = applyVC.next(); .... }
i want to do a select multiple double side
like this : http://www.senamion.com/blog/jmultiselect2side.html (Demo2)
but i don't know how i can retrieve my data when i click submit button..?
It looks like, assuming your select has the name "secondSelect[]" as per the demo page, the two generated selects will have the names "secondSelectms2side__sx" and "secondSelectms2side__dx"
So it is these names you should be looking for in the request object