This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes JSF and the fly likes can't get selectManyCheckbox values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "can Watch "can New topic
Author

can't get selectManyCheckbox values

marwa talaat
Greenhorn

Joined: Dec 28, 2011
Posts: 2
i'm a newbie in JSF1.2 and it is my first task.
when i select many checkbox in jsf page the result jsf page doesn't view checkboxs values

this is my code

addCustomer.jsp
<h:column>Favorite Hobbies</h:column>
<h:column>
<h:selectManyCheckbox>
<f:selectItem itemValue="Reading" itemLabel="Reading"/>
<f:selectItem itemValue="Swiming" itemLabel="Swiming"/>
<f:selectItem itemValue="Watching TV" itemLabel="Watching TV"/>

</h:selectManyCheckbox>
</h:column>
<h:commandButton value="Register Now" action="submit"></h:commandButton>

AddCustomer.java

package com.jsf.model;
import java.util.HashMap;
import java.util.Map;

public class AddCustomer {
private Map<String,String>favorite;

public Map<String, String> getFavorite() {
favorite= new HashMap<String, String>();
favorite.put("Reading","Reading");
favorite.put("Swiming","Swiming");
favorite.put("Watching TV","Watching TV");
return favorite;
}
public void setFavorite(Map<String, String> favorite) {
this.favorite= favorite;
}
}



ViewCustomer.jsp
<h:column>favorite</h:column>
<h:column>
<c:forEach items="#{addCustomer.favorite}" var="fav">
<hutputText value="#{fav}"/>
</c:forEach>
</h:column>



face-config.xml

<managed-bean>
<managed-bean-name>addCustomer</managed-bean-name>
<managed-bean-class>com.jsf.model.AddCustomer</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<display-name>pages/addCustomer</display-name>
<from-view-id>/pages/addCustomer.jsp</from-view-id>
<navigation-case>
<from-outcome>submit</from-outcome>
<to-view-id>/pages/viewCustomer.jsp</to-view-id>
</navigation-case>
</navigation-rule>

Louis Bros
Ranch Hand

Joined: Jun 03, 2011
Posts: 54

Won't your checkbox be needing a value referencing a corresponding setter method in your bean?

I'm just curious, since you're learning JSF why don't you start with JSF 2.0?


OCA7
rose holcomb
Greenhorn

Joined: Dec 28, 2011
Posts: 1
review every line you input. in order to stop spelling errors. programming is very sensitive.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can't get selectManyCheckbox values