| 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
Greenhorn
Joined: Jan 24, 2012
Posts: 21
|
|
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 );
}
}
|
 |
 |
|
|
subject: how to move a variable's value from bean page to another java class
|
|
|