Hello. I am currently learning how to use jsf and i have a big problem that I don't know how to solve. I might not even be able to explain very accurate what the problem is but I will try.
Here it goes:
I have a page, admin.jsp, where you can perform CRUD operations on a table. The problem i have is with the Read action. In order to read users from the db, you insert the username and then press Read button. The users whose username is similar to the one inserted by the user are displayed in a datatable, on another page (data.jsp). The problem is, how do I transfer the username from one page to another? I have a bean, called "login_bean" where the username is kept, as long as I perform some operation from the bean on the admin.jsp page. But once I go to another page, username dissappears. I will post some code, hopefully it will become clearer.
PS: I simplifid the code and left only info concerning username, hoping that it will become easier to understand
I must mention that everything I did here was taken from internet examples. I don't know jsf/jsp, I needed to make a project for the university in 2 weeks, and I did not have much time to repare.
Joined: Jul 08, 2011
I need to know how I can make the username in java_bean remain the same as it is in admin.jsp when the user presses "read" button and transfers him to data.jsp page
It is better to use on jsf page mainly jsf components. Instead of <table> use <h:dataTable>
If you want to pass some parameter from one page to another look at this simple sample:
This is command button that can execute some method of bean and navigate to next page by 'action' attribute:
Of course it is only part of that page. <f:viewparam> element takes id passed from previous page and stores id in bean.selectedEventId.
It is important to have attribute 'name' of f:param and <f:paramview> with identical value on both pages. Also action attribute must include- includeViewParams=true
It's even better not to put parameters on pages at all. They add to network traffic, they offend the MVC architecture by blurring the separation between Model and View, and they can be exploited by hackers.
JSF is designed to keep most of its data on the server side, therefore you usually shouldn't send data out to the View and back in again as parameters, you should simply transfer the data from backing bean to backing bean.
I could do an entirely different rant on user-coded logins and why they are even more insecure than parameters on the View, but I'll probably do that somewhere else today anyway.
Customer surveys are for companies who didn't pay proper attention to begin with.