| 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">
<h utputText 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.
|
 |
 |
|
|
subject: can't get selectManyCheckbox values
|
|
|