File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes how to move a variable's value from bean page  to another java class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "how to move a variable Watch "how to move a variable New topic
Author

how to move a variable's value from bean page to another java class

Swela Jathar
Greenhorn

Joined: Aug 19, 2011
Posts: 22
Hi,

I am totally new to JSF 2.0.I am creating simple registration form using mysql 5.1,and netbeans 6.5.and i have created separate java class for database connection.i have written insert query in that class.n i want to access variables from jsf bean page(i.e bean.java).
how to move a variable's value from jsf's bean page to another java class?
Thanks in advance...
Jhonnathan Emilio Cardona Saineda
Ranch Hand

Joined: Jan 24, 2012
Posts: 37

here is the page.jsp... and a input field..-->
<f:view>
...
<h:inputText id="helloInput" value="#{helloBean.number}"
required="true">
</h:inputText>
....
<h:commandButton id="button" type="submit"
value="send"
actionListener="#{helloBean.action}"/>
...
</f:view>

and here is bean.java

public class HelloBean
{....
private int number;
//this property is sincronized with the page
public int getNumber()
{
return numControls;
}
public void setNumber(int number )
{
this.number = number ;
}

// method fired by the button

public void action(ActionEvent actionEvent)
{
Javaclassfordatabaseconnection miClass = Javaclassfordatabaseconnection();
miClass.insert( number );
}

}


Sorry for my English, I'll improve
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to move a variable's value from bean page to another java class