• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Swela Jathar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 38
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 );
}

}
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic