Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-17-2008, 01:59 PM
Member
 
Join Date: Jan 2008
Posts: 1
crispy is on a distinguished road
how to read a form with JFS
hi all,
i have a simple form like this:

Code:
<h:form styleClass="form" id="registrationForm"> <table> <tr> <td>Lastname:</td> <td><h:inputText id="lastname" value=""></h:inputText></td> </tr> <tr> <td>Firstname:</td> <td><h:inputText id="firstname" value=""></h:inputText></td> </tr> <tr> <td>Username:</td> <td><h:inputText id="username" value=""></h:inputText></td> </tr> <tr> <td>E-Mail:</td> <td><h:inputText id="email" value=""></h:inputText></td> </tr> <tr> <td><br> </td> <td></td> </tr> <tr> <td>Password:</td> <td><h:inputSecret id="password1" styleClass="inputSecret" value=""></h:inputSecret></td> </tr> <tr> <td>Confirm Password:</td> <td><h:inputSecret id="" styleClass="inputSecret" value="test3t2"></h:inputSecret></td> </tr> </table> <br> <hx:commandExButton value="Submit" action="#{pc_Register.doRegistration}" styleClass="commandExButton" id="button1"></hx:commandExButton> <br> </h:form>
now how can i get this data in my doRegistration() method?

when i do something like this
this.getRequestParam().values().toArray();

i get an array with all my data, but i'm sure there's a way to get a specific value, for example the username by something like getRequestParam().getParam('username'); or something similar.

thanks for any help!
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-20-2008, 06:26 AM
Member
 
Join Date: Jan 2008
Posts: 2
loveshore is on a distinguished road
Crispy,
What i understand is that, you want to get all your component values in the doRegisteration() method.For this you don't need to put any extra effort. Since all managed beans are POJO's you can use the instance variables directly in the instance method.
I'm also a junior in the JSF world and hope i'm not confusing you.Anyway i'm attaching a piece code that can give you a more clear picture on this.


public class UserBean
{
private String firstName;

/**
* @return
*/
public String getFirstName() {
return firstName;
}

/**
* @param string
*/
public void setFirstName(String string) {
firstName = string;
}
public String registerUser() // your doRegistration method here
{
System.out.println("***ADDING REGISTERED USER ** ***"+firstName);
//You may add this user details to database or process in some other way, as usual
return "registered";
}

}
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-01-2008, 04:07 PM
Member
 
Join Date: May 2008
Posts: 1
hackerofcrackers is on a distinguished road
solution to your JSF parameters problem
hi,

I am new to this forum, anyways, the solution to your problem:

In the "doRegistration" method of your bean, get the HttpServletRequest object as below:

HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstanc e().getExternalContext().getRequest();

then,

use the below code to get the paramters of each of the "id":

String x = request.getParameter("registrationForm:lastname");

NOTE: The "colon" is very important. formid:component_id

Hope this definitely help you.

Srinivas.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Notes creel Java Applets 0 02-02-2008 02:25 AM
1 form 2 servlets sandor Java Servlet 2 01-22-2008 11:47 AM
center a form tommy New To Java 2 08-06-2007 09:47 PM
Some form to read pixels in Java and to handle Another plate VGA? Albert Advanced Java 1 06-07-2007 06:29 AM
Form Help Pls CoOlbOyCoOl NetBeans 4 05-27-2007 09:31 AM


All times are GMT +3. The time now is 09:36 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org