Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSF-Questions JSF binding attribute
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


sreenivas
JSF binding attribute
3 Answer(s)      6 years ago
Posted in : Java Server Faces Questions



Advertisement
View Answers

December 30, 2008 at 5:47 AM


Hi friend,

Code to help in solving the problem :

JavaBeans are used to associate the UI components. This backing bean (JavaBean) contains properties that are bound to either component value or component instance. Both types of binding requires use of Expression Language (EL) syntax. A component instance can be bound to the bean property by referencing the property in the "binding" attribute of the tag associated with the component.

"login.jsp"

<%@ taglib uri="http://java.sun.com/jsf/html"; prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f" %>

<f:view>
<html>
<head><title>JSF Login Example By Using Component Binding</title></head>

<body>
<h:form>
<table>
<tr>
<td><h:outputText value="Enter Login ID: " /></td>
<td><h:inputText id="loginname"
binding="#{LoginWithCompBinding.loginname}" /></td>
</tr>
<tr>
<td><h:outputText value="Enter Password: " /></td>
<td><h:inputSecret id="password"
binding="#{LoginWithCompBinding.password}" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><h:commandButton value="Login"
action="#{LoginWithCompBinding.CheckValidUser}" /></td>
</tr>
</table>
</h:form>
</body>
</html>
</f:view>


December 30, 2008 at 5:47 AM


"LoginWithCompBinding.java" Javabean

package roseindia;

import javax.faces.component.html.HtmlInputSecret;
import javax.faces.component.html.HtmlInputText;

public class LoginWithCompBinding{
HtmlInputText loginname;
HtmlInputSecret password;

public LoginWithCompBinding(){}

public String CheckValidUser(){
if(loginname.getValue().equals("administrator") &&
password.getValue().equals("admin"))
return "success";
else
return "fail";
}

public HtmlInputText getLoginname(){
return loginname;
}

public void setLoginname(HtmlInputText loginname){
this.loginname = loginname;
}

public HtmlInputSecret getPassword(){
return password;
}

public void setPassword(HtmlInputSecret password){
this.password = password;
}
}


December 30, 2008 at 5:48 AM


faces-config.xml :

<?xml version="1.0"?>
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">;

<faces-config>
<managed-bean>
<managed-bean-name>LoginWithCompBinding</managed-bean-name>
<managed-bean-class>roseindia.LoginWithCompBinding</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/pages/login.jsp</from-view-id>
<navigation-case>
<from-action>#{LoginWithCompBinding.CheckValidUser}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/pages/resultforsuccess.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-action>#{LoginWithCompBinding.CheckValidUser}</from-action>
<from-outcome>fail</from-outcome>
<to-view-id>/pages/resultforfail.jsp</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>

For read more information on JSF visit to :

http://www.roseindia.net/jsf/

Thanks


Related Tutorials/Questions & Answers:
Why binding attribute is required in jsf frame work
Why binding attribute is required in jsf frame work  Why binding attribute is required in jsf frame work. And what use of binding attribute
JSF binding attribute - Java Server Faces Questions
JSF binding attribute  Hi frnds.. Can anyone please enlighten me about binding attribute in JSF... how can we use binding attribute...please give... by referencing the property in the "binding" attribute of the tag associated
Advertisements
value and binding attribute
value and binding attribute  What is the difference between value and binding attribute of jsf tag
value and binding attribute
value and binding attribute  What is the difference between value and binding attribute in jsf
jsf attribute
jsf attribute  What is the different between value and binding attribute of jsf
JSF Rendered Attribute
JSF Rendered Attribute  i need the example for jsf with rendered attribute
Action attribute in Jsf framework - Development process
Action attribute in Jsf framework  There will be one welcome.jsp... which will get the information from database.so action attribute... to action attribute of the welcome.jsp /welcome.jsp
JSF with Facelets - Problem setting attribute maxlength - Java Server Faces Questions
JSF with Facelets - Problem setting attribute maxlength  Hi, I have just started working on JSF along with facelets. I have created a xhtml file that contains a widget. I want to set the maxlength attribute of the text field
JSF Login Example By Using Component Instance Binding
JSF Login Example By Using Component Instance Binding... value or component instance. Both types of binding requires use... property by referencing the property in the "binding" attribute
DYNAMIC BINDING
DYNAMIC BINDING  WHAT IS DYNAMIC BINDING
Binding in Flex
Binding in Flex  Hi....... Explain how binding works in mxml components? Please give the answer with example. Thanks  Ans: Binding in MXML Please see the following code: <s:Button id="btn" label
Binding in flex
Binding in flex  Hi......... Please tell me the Difference between...: 1. When we define a data binding in MXML it will use at compile time and we define a data binding in action script it will use at run time. 2. you use
Context binding
Context binding  What is meant by Context binding?   A binding context is an object that holds data that you can reference from your... a hierarchy of binding contexts. The root level of the hierarchy refers to the viewModel
Binding Component Value to an Implicit Object
Binding Component Value to an Implicit Object          JSF provides list of implicit objects. These objects can be referred in value attribute
Binding Error in Spring - Spring
Binding Error in Spring  Error: Neither BindingResult nor plain target object for bean name 'loginBean' available as request attribute I am trying to write a login page in Springs My jsp: User Id : ">
JSF
JSF  What is JSF
XML data binding
XML data binding   hello, What is XML data binding?   hii, XML data binding refers to the process of representing the information in an XML document as an object in computer memory
Binding - Java Interview Questions
Binding   Hi Deepak , Interface makes runtime binding where abstract class is compile time binding.you can achieve multiple inheritance through Interface but abstract class not allow. Thank u in advance
Flex data binding example
Flex data binding example       In the example below, data binding in flex is demonstrated. Here data binding means binding or connecting the properties or attributes of flex
JSF
JSF  In what way JSF makes the difference between Applets?? After reading this article I understood instead of using Request and response, we... and embed that into applets also rite.. Do u mean JSF also does the same internally
Binding and unbinding events
Binding and unbinding events       Binding and unbinding events As the name says "binding events " is  the association of an element
Overriding jaxb binding at client side?
Overriding jaxb binding at client side?  How can override jaxb binding at client side? I have a webservice client which creates xmlgregoriancalendar.... Overriding jaxb binding at client side
binding data with textbox on dropdown click
binding data with textbox on dropdown click  Hello friends,Divyesh here. i have jsp page and i would like to bind data with text box on dropdown click. in dropdown employee id are load.and when we select perticular id than how
what is difference between one-way data binding and two-way data binding?
what is difference between one-way data binding and two-way data binding?  what is difference between one-way data binding and two-way data binding? Thanks
PHP Late Static Binding
PHP Late Static Binding: A new feature called late static binding is introduced in PHP 5.3.0 which can be used to refer the called class. The name late static binding is coined because of the static:: will no longer be resolved using
multivalued attribute
multivalued attribute  I have a author as multivalued attribute and i have inserted values for it in database but now how to insert values in the database through form .I have written query as shown below and iam getting error
multivalued attribute?
multivalued attribute?  I have a problem in editing the database through form because of multivalued attribute it is creating the error and also how to write code for displaying the data when there is multivalued attribute
multivalued attribute?
multivalued attribute?  I have a problem in editing the database through form because of multivalued attribute it is creating the error and also how to write code for displaying the data when there is multivalued attribute
JSF architecture
JSF architecture  What is JSF architecture
Advertisements
 

 

 

DMCA.com