change table based on selected value from database in JSP - java

I need to change the values displayed in the timetable based on the room I select from the dropdown list but I don't know how to do it.
The code for dropdown list is:
select option list
And on the same page, the code for the timetable:
timetable JSP page
Right now it shows all values from the database regardless of the selected room.

AJAX(Asynchronous Javascript and XML) can do this for you. AJAX allows for the updating of contents within an HTML object without reloading the page. W3Schools and the JQuery reference both have lots of helpful info on the matter.

Related

Oracle ADF stop validation on empty table row, validate in popup form instead

I'm currently developing a simple application which does crud operations on a few tables.
It looks like this:
I have a problem with the add item form, invoked by pressing the button saying "Nova jedinica mjere". It opens a popup containing an ADF form as follows:
As you can see it does a create insert operation on popup fetch event, creating an empty row. When I fill the form with data, and press OK(the ok button is handled in the bean, doing a commit operation), I get an empty error message as follows:
This only happens if the table is editable(consisting of input text elements). If it is set to click to edit, this problem does not occur. How can I make validation only occur on form fields?
If you need any more info, please let me know because I too am new to adf.
EDIT:
This is the page in question:(posted as a pastebin link to not take up much space).
http://pastebin.com/5TKyPxEs
The form in the popup is a static region from a task flow with a method call and a page:
http://pastebin.com/9h69fRW4
You mean to say that when you enter the value in the form and Click OK, it should be there in the Table,If so, the values are not getting displayed in Table. It means your Iterator is not fetching the values. You have to Refresh your Iterator, VO and Table Compoent through Bean. So that the values in the form once you click OK, it will be there in the Table.

Display data from database using Javascript in Java code

I am using java and jsp to display my data.
I want to use javascript to display data from database on select of item from dropdown list.
i.e. i have a form where on selecting an item from a dropdown list the information of that item should be displayed.
How should I start it?

Passing select row of HTML table to next JSP page

I created a HTML data table in a page say DATABROWSER.JSP through Java script (including all its row and there on click function in JS). I want to pass the selected(highlighted) row value to another JSP page(a new page that i open after selecting) without submiting the first page. !!
There's no way to get to another JSP without going back to the server.
I would place the items you select in hidden form fields and then submit the form. This would allow you to bring back a new JSP.

JSP menu design advice

I'm looking to create a horizontal menu in a jsp page - the menu items vary by user but stay consistent over every page in the site for that user apart from the appearance of the active tab. Seems a simple enough problem at first (the appearance is modified using css) but I can't decide where to construct the menu.
Menu code:
<ul>
<li>item1</li>
<li id="active">item2</li>
</ul>`
As I see it there are 3 choices of when to retrieve menu items:
Upon receipt of HTTP Request to any controller for the first time store two arrays in the session - [url1, url2] and [item1, item2]. Then make the all the jsp pages form this into the above code. The jsp would have to know it's url to make against the [url1, url2] array in order to insert the active id.
Create the above html separately in each controller. Since a controller knows it's own url, it's simple to add the active id.
Create above html without any active id, store the html in the session and make either the jsp pages/controllers modify the html string.
None of these seem particularly appetising.
Does anyone have any advice on this?
Since a JSP is where all the HTML belongs, I'd go for option 1, but then with a List<MenuItem> instead of two loose arrays. You can find JSP's own URL by ${pageContext.request.requestURI}. The JSTL functions library should be helpful in determining whether the URL matches.

Add.jsp and Update.jsp or only one

How many JSPs to create to maintain one table for data entry. Add.jsp to enter a new record and Update.jsp to update an already entered record. Is this a good idea or create only one jsp and use that for add and update using some parameter as all the fields and functionality remains same. Only difference is at the time of update few fields will be disabled and you need to pre-populate the form. I can use struts or jsf to develop this.
Better use one page, and differentiate between new and existing based on some criteria - for example, if the id of the object is 0.
Even if you make two pages, you can include the common content so that you don't copy-paste.
I like the one page approach too.
You could have a dropdown box containing the ids' or some other value that provides an easy way for the user to find a specific record and whatever other html elements you need on the page for displaying a record.
They make a choice using the drop down box if they wish to edit a record and then that records data is displayed on the page for editing, the user enters the corrections and hits the submit button.
If they want to enter a new record, then they do not make a choice using the dropdown box and instead just fill in the fields on the page and hit submit.
When posting back to the page you can check and see if a selection was made using teh dropdown box and if not enter a new record and if a choice was made then you update the record that corresponds to the selection made from the dropdown box.

Categories

Resources