JavaBeat
calling cards | international calling cards | phone card
Search JavaBeat

JAVABEAT
home
tips
articles
QnA
forums
TIPS TOPICS
Java Basics
JSP
JSF
Spring
Hibernate
EJB 3.0
JMS
Log4j
Ant
Eclipse
Netbeans
ARCHIVE
2008 | 08 07 06 05 04 03 02 01
2007 | 12 11 10 09 08
Enter email address:

Latest JavaBeat Tips Delivered
OUR NETWORK
javabeat
planetoss

h:selectManyCheckBox - Java Server Faces (JSF)

You may be interested...
Life Cycle of JSF Components
JSF Best Practices
New Features in JSF 2.0
Implement Internationalization and Localization in JSF
Creating simple toolbar using RichFaces tag library
Have a look at this...
JSP | JSF | Spring | Hibernate
EJB 3.0 | JMS | Log4j | Eclipse | Netbeans
Free Subscription
Enter email address:

Latest JavaBeat Tips Delivered
Author : JavaBeat
Date : Sat Apr 12th, 2008
Topic : jsf
Add to: Digg Add to: Del.icio.us Add to: Reddit Add to: StumbleUpon Add to: Slashdot Add to: Yahoo Add to: Google Add to: Blinklist Add to: Technorati Information

  • Topic : Java Server Faces (JSF)
  • Environment : J2EE 5.0, MyFaces 1.1.5
  • Discuss Here

selectManyCheckBox.jsp

	

<!--
   Source : www.javabeat.net
-->
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>

<html>
    <body>
          <f:view>
              <h:form id="select">
                  <h:panelGrid columns="1">
                       <h:column>
                          <h:outputText value="Select Countries: "/>
                          <h:selectManyCheckbox value="#{selectManyCheckBoxBean.selectedItems}">
                              <f:selectItem itemLabel="India" itemValue="India" />
                              <f:selectItem itemLabel="China" itemValue="China" />
                              <f:selectItem itemLabel="Germany" itemValue="Germany" />
                              <f:selectItem itemLabel="USA" itemValue="USA" />
                          </h:selectManyCheckbox>
                      </h:column>
                      <h:column>
                          <h:commandButton value="Submit" action="#{selectManyCheckBoxBean.submit}"/>
                      </h:column>
                  </h:panelGrid>
              </h:form>
          </f:view>
    </body>
</html>


	

selectManyCheckBoxBean.java

	
/**
 *  Source : www.javabeat.net
 * */
package net.javabeat.myfaces.checkbox;

import java.util.List;

public class SelectManyCheckBoxBean {
    
    private List<String> selectedItems;
    public SelectManyCheckBoxBean() {
    }

    public List<String> getSelectedItems() {
        return selectedItems;
    }

    public void setSelectedItems(List<String> selectedItems) {
        this.selectedItems = selectedItems;
    }
    public String submit(){
        System.out.println("List : " + this.selectedItems);
        return "selectManyCheckBox";
    }
}


	

faces-config.xml

	
<managed-bean>
	<managed-bean-name>selectManyCheckBoxBean</managed-bean-name>
	<managed-bean-class>net.javabeat.myfaces.checkbox.SelectManyCheckBoxBean</managed-bean-class>
	<managed-bean-scope>request</managed-bean-scope>        
</managed-bean>    
<navigation-case>
	<from-outcome>selectManyCheckBox</from-outcome>
	<to-view-id>/pages/checkbox/selectManyCheckBoxResult.jsp</to-view-id>
</navigation-case>      
	

selectManyCheckBoxResult.jsp

	
<!--
   Source : www.javabeat.net
-->
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>

<html>
    <body>
          <f:view>
              <h:form id="select">
                  <h:panelGrid columns="1">
                       <h:column>
                          <h:outputText value="Selected Countries: "/>
                          <h:dataTable value="#{selectManyCheckBoxBean.selectedItems}" var="loc">
                              <h:column>
                                <h:outputText value="#{loc}"/>
                            </h:column>
                          </h:dataTable>
                      </h:column>
                  </h:panelGrid>
              </h:form>
          </f:view>
    </body>
</html>


	


Favorites
AffiliatedAds.com
Buy movies
Access Control
Busby seo challenge contest
Sohbet
Chat
Webmaster Hosting Forum
Java Jobs
MyVideoLib
India News
Internet Advances
Sohbet
chat
Latest QnA
SCJD Tips
When we start a thread by applying start() method on it ,how does it knows that to execute run()method?
About Wrapper class in Java
How to configure weblogic 7.0 in MyEclipse?
Static Block and Static Initializer in Java

JavaBeat Website (2004-2008), India
javabeat | about us | planetoss
Copyright (2004 - 2008), JavaBeat