myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slayer666 <rfu...@hotmail.es>
Subject Re: JSF selectMany Tag problem
Date Thu, 24 Jun 2010 09:15:40 GMT

Hi, sorry but I forgott to post the Select bean class.

package jsf.beans;

import javax.faces.model.SelectItem;

public class Select extends SelectItem {
	private String team1;
	private String team2;
	private String team3;
	
	public Select(String v,String l){
		super(v,l);
	}
	
	public String getTeam1() {
		return team1;
	}
	public void setTeam1(String team1) {
		this.team1 = team1;
	}
	public String getTeam2() {
		return team2;
	}
	public void setTeam2(String team2) {
		this.team2 = team2;
	}
	public String getTeam3() {
		return team3;
	}
	public void setTeam3(String team3) {
		this.team3 = team3;
	}
	
	

}

As you can see this class extends from SelectItem class so theoretically i
have implemented a List of SelectedItems.

Thanks.


Mike Kienenberger wrote:
> 
> That's a new way (to me) to initialize a selectItems list.
> 
> Are you certain that your "groups" beans are SelectItem instances?
> 
> On Tue, Jun 22, 2010 at 6:51 AM, slayer666 <rfunez@hotmail.es> wrote:
>>
>> Good morning, i am trying the JSF selectManyMenu tag and i when i execute
>> the
>> aplication renders this trace log:
>>
>> javax.servlet.ServletException
>>        javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
>>
>>
>> causa raíz
>>
>> java.lang.NullPointerException
>>
>> org.apache.catalina.connector.CoyoteWriter.write(CoyoteWriter.java:171)
>>
>> com.sun.faces.application.ViewHandlerImpl$WriteBehindStateWriter.write(ViewHandlerImpl.java:867)
>>
>> com.sun.faces.renderkit.html_basic.HtmlResponseWriter.write(HtmlResponseWriter.java:620)
>>
>> com.sun.faces.renderkit.html_basic.MenuRenderer.renderOption(MenuRenderer.java:539)
>>
>> com.sun.faces.renderkit.html_basic.MenuRenderer.renderOptions(MenuRenderer.java:772)
>>
>> com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:832)
>>
>> com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:280)
>>
>> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861)
>>        javax.faces.component.UIComponent.encodeAll(UIComponent.java:937)
>>        javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
>>
>> javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
>>        javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
>>        javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
>>
>> com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:266)
>>
>> com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:197)
>>
>> com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
>>        com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
>>      
>>  com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
>>        javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
>>
>> This are the codes implemented:
>>
>> *faces-config.xml
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>>
>> <faces-config
>>    xmlns="http://java.sun.com/xml/ns/javaee"
>>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
>> http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
>>    version="1.2">
>>
>>    <application>
>>      <resource-bundle>
>>        <base-name>jsf.properties.Application</base-name>
>>        <var>label</var>
>>      </resource-bundle>
>>    </application>
>>    <managed-bean>
>>      <managed-bean-name>groups</managed-bean-name>
>>      <managed-bean-class>java.util.ArrayList</managed-bean-class>
>>      <managed-bean-scope>session</managed-bean-scope>
>>      <list-entries>
>>        <value-class>jsf.beans.Select</value-class>
>>        <value>#{groupA}</value>
>>      </list-entries>
>>    </managed-bean>
>>    <managed-bean>
>>      <managed-bean-name>groupA</managed-bean-name>
>>      <managed-bean-class>jsf.beans.Select</managed-bean-class>
>>      <managed-bean-scope>session</managed-bean-scope>
>>      <managed-property>
>>         <property-name>team1</property-name>
>>         <value>Brazil</value>
>>      </managed-property>
>>      <managed-property>
>>         <property-name>team2</property-name>
>>         <value>Korea</value>
>>      </managed-property>
>>      <managed-property>
>>         <property-name>team3</property-name>
>>         <value>Portugal</value>
>>      </managed-property>
>>    </managed-bean>
>>    <managed-bean>
>>      <managed-bean-name>login</managed-bean-name>
>>      <managed-bean-class>jsf.beans.LoginBean</managed-bean-class>
>>      <managed-bean-scope>request</managed-bean-scope>
>>      <managed-property>
>>        <property-name>minimum</property-name>
>>        <value>18</value>
>>      </managed-property>
>>    </managed-bean>
>>    <navigation-rule>
>>      <from-view-id>/index.jsp</from-view-id>
>>      <navigation-case>
>>        <from-outcome>loginSuccess</from-outcome>
>>        <to-view-id>/success.jsp</to-view-id>
>>      </navigation-case>
>>    </navigation-rule>
>>    <navigation-rule>
>>      <from-view-id>/success.jsp</from-view-id>
>>      <navigation-case>
>>        <from-outcome>home</from-outcome>
>>        <to-view-id>/index.jsp</to-view-id>
>>      </navigation-case>
>>      <navigation-case>
>>        <from-outcome>populate</from-outcome>
>>        <to-view-id>/bookStore.jsp</to-view-id>
>>      </navigation-case>
>>    </navigation-rule>
>> </faces-config>
>>
>> *login.jsp
>>
>>          <h:selectManyMenu value="#{login.groupsWorldCup}">
>>            <f:selectItems value="#{groups}"/>
>>          </h:selectManyMenu>
>>
>> *LoginBean.java
>>
>> package jsf.beans;
>>
>> import java.util.ArrayList;
>>
>> import javax.faces.application.FacesMessage;
>> import javax.faces.component.UIComponent;
>> import javax.faces.component.UIInput;
>> import javax.faces.context.FacesContext;
>>
>> public class LoginBean {
>>        private String userName;
>>        private String passwd;
>>        private Integer age=null;
>>        private String text;
>>        private int minimum;
>>        private boolean check;
>>        private String language;
>>        private ArrayList<BookBean> bookList=new ArrayList<BookBean>();
>>        private String style;
>>        private ArrayList<String> role=new ArrayList<String>();
>>        private ArrayList<String> menuList=new ArrayList<String>();
>>        private ArrayList<String> groupsWorldCup=new ArrayList<String>();
>>
>>        public String getUserName() {
>>                return userName;
>>        }
>>
>>        public void setUserName(String userName) {
>>                this.userName = userName;
>>        }
>>
>>        public String getPasswd() {
>>                return passwd;
>>        }
>>
>>        public void setPasswd(String passwd) {
>>                this.passwd = passwd;
>>        }
>>
>>        public Integer getAge() {
>>                return age;
>>        }
>>
>>        public void setAge(Integer age) {
>>                this.age = age;
>>        }
>>
>>        public int getMinimum() {
>>                return minimum;
>>        }
>>
>>        public void setMinimum(int minimum) {
>>                this.minimum = minimum;
>>        }
>>
>>        public String getText() {
>>                return text;
>>        }
>>
>>        public void setText(String text) {
>>                this.text = text;
>>        }
>>
>>        public ArrayList<BookBean> getBookList() {
>>                return bookList;
>>        }
>>
>>        public void setBookList(ArrayList<BookBean> bookList) {
>>                this.bookList = bookList;
>>        }
>>
>>        public boolean isCheck() {
>>                return check;
>>        }
>>
>>        public void setCheck(boolean check) {
>>                this.check = check;
>>        }
>>
>>        public String getLanguage() {
>>                return language;
>>        }
>>
>>        public void setLanguage(String language) {
>>                this.language = language;
>>        }
>>
>>        public String getStyle() {
>>                return style;
>>        }
>>
>>        public void setStyle(String style) {
>>                this.style = style;
>>        }
>>
>>        public ArrayList<String> getRole() {
>>                return role;
>>        }
>>
>>        public void setRole(ArrayList<String> role) {
>>                this.role = role;
>>        }
>>
>>        public ArrayList<String> getMenuList() {
>>                return menuList;
>>        }
>>
>>        public void setMenuList(ArrayList<String> menuList) {
>>                this.menuList = menuList;
>>        }
>>
>>        public ArrayList<String> getGroupsWorldCup() {
>>                return groupsWorldCup;
>>        }
>>
>>        public void setGroupsWorldCup(ArrayList<String> groupsWorldCup)
{
>>                this.groupsWorldCup = groupsWorldCup;
>>        }
>>
>>        public void checkUsername(FacesContext fcontext,UIComponent
>> component,Object value){
>>                String msg=(String)value;
>>                if(!msg.equals("raul")){
>>                        ((UIInput)component).setValid(false);
>>                      
>>  fcontext.addMessage(component.getClientId(fcontext),
>> new FacesMessage("Usuario incorrecto"));
>>                }
>>        }
>>
>>        public void checkPasswd(FacesContext fcontext,UIComponent
>> component,Object value){
>>                if(!value.equals("vaji97")){
>>                        ((UIInput)component).setValid(false);
>>                      
>>  fcontext.addMessage(component.getClientId(fcontext),
>> new FacesMessage("Clave incorrecta"));
>>                }
>>        }
>>
>>        public String populateBookList(){
>>                this.bookList.add(new BookBean(2,"Lord of the Rings",34));
>>                this.bookList.add(new BookBean(3,"Codigo DVinci",38));
>>                this.bookList.add(new BookBean(1,"Angels and Evils",36));
>>                this.bookList.add(new BookBean(4,"Geisha history",27));
>>                return "populate";
>>        }
>> }
>>
>>
>> Any suggestions?.
>>
>> Thanks in advanced.
>> --
>> View this message in context:
>> http://old.nabble.com/JSF-selectMany-Tag-problem-tp28958641p28958641.html
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/JSF-selectMany-Tag-problem-tp28958641p28980436.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Mime
View raw message