Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Friday, November 30, 2007

How to Change Bean Property in java

//This example is from Jakub Czeczotka

//web.xml


xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">


ChangeBeanProperty



Change a property of a simple bean




org.apache.myfaces.webapp.StartupServletContextListener




Faces Servlet
javax.faces.webapp.FacesServlet
1



Faces Servlet
*.jsf



index.jsp





//faces-config.xml


"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">



simpleBean
eu.czeczotka.SimpleBean
session




//SimpleBean.java

package eu.czeczotka;


import java.util.logging.Logger;


/**
* Simple bean for the ChangeBeanProperty project
*
* @author Jakub Czeczotka
*/
public class SimpleBean {

private Logger logger = Logger.getLogger ("eu.czeczotka.SimpleBean");
private String property = "initial value";

public String getProperty () {
return this.property;
}

public void setProperty (String property) {
logger.info ("changing property value from \"" +
this.property + "\" to \"" + property + "\"");
this.property = property;
}
}


//index.jsp

<% response.sendRedirect("changeBeanProperty.jsf"); %>

//changeBeanProperty.jsp

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

<%-- ChangeBeanProperty - author Jakub Czeczotka --%>



ChangeBeanProperty




Change a property of a simple bean








No comments: