Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can't get selectManyCheckbox values

 
marwa talaat
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 54
Java Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
rose holcomb
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
review every line you input. in order to stop spelling errors. programming is very sensitive.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic