[richfaces-issues] [JBoss JIRA] (RF-12546) h:selectOneMenu with f:selectItems layout problem

Brian Leathem (JIRA) jira-events at lists.jboss.org
Tue Oct 23 12:40:01 EDT 2012


     [ https://issues.jboss.org/browse/RF-12546?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Brian Leathem updated RF-12546:
-------------------------------

    Steps to Reproduce: 
Create a new.user.xhtml file :

{code}
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

<h:head>
	<title>Test</title>
</h:head>

<h:body>
	<h:form>
		<h:panelGrid columns="2">

			<h:outputText value="User name" />
			<h:inputText value="#{dataBean.user.name}" />

			<h:outputText value="Profile" />
					<h:selectOneMenu value="#{dataBean.profiles}">
				<f:selectItems value="#{dataBean.profiles}" var="p"
					itemLabel="#{p.name} - #{p.id}" itemValue="#{p.id}" />
					</h:selectOneMenu>

			<h:outputText value="Last update" />
			<rich:calendar />

		</h:panelGrid>

	</h:form>
</h:body>
</html>
{code}

and a DataBean class :

{code}
import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean
@SessionScoped
public class DataBean {
	User user;
	
	public List<Profile> getProfiles(){
		List<Profile> profiles = new ArrayList<Profile>();
		profiles.add(new Profile(1L,"Profile 1"));
		profiles.add(new Profile(2L,"Profile 2"));
		profiles.add(new Profile(3L,"Profile 3"));
		profiles.add(new Profile(4L,"Profile 4"));
		profiles.add(new Profile(5L,"Profile 5"));
		return profiles;
	}
	
	public User getUser() {
		return user;
	}
}

Dependent classes are :

public class Profile {
	Long id;
	String name;
	Long profileId;
	
	public Profile(){
		
	}

	public Profile(Long id, String name) {
		super();
		this.id = id;
		this.name = name;
	}


	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	
}

and

public class User {
	Long id;
	String name;
	Long profileId;
	public User(){
		
	}


	public User(Long id, String name) {
		super();
		this.id = id;
		this.name = name;
	}


	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public User(Long id, String name, Long profileId) {
		super();
		this.id = id;
		this.name = name;
		this.profileId = profileId;
	}


	public Long getProfileId() {
		return profileId;
	}


	public void setProfileId(Long profileId) {
		this.profileId = profileId;
	}
	
	
}
{code}

Then open the new.user.xhtml. The layout is broken

  was:
Create a new.user.xhtml file :
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

<h:head>
	<title>Test</title>
</h:head>

<h:body>
	<h:form>
		<h:panelGrid columns="2">

			<h:outputText value="User name" />
			<h:inputText value="#{dataBean.user.name}" />

			<h:outputText value="Profile" />
					<h:selectOneMenu value="#{dataBean.profiles}">
				<f:selectItems value="#{dataBean.profiles}" var="p"
					itemLabel="#{p.name} - #{p.id}" itemValue="#{p.id}" />
					</h:selectOneMenu>

			<h:outputText value="Last update" />
			<rich:calendar />

		</h:panelGrid>

	</h:form>
</h:body>
</html>

and a DataBean class :


import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean
@SessionScoped
public class DataBean {
	User user;
	
	public List<Profile> getProfiles(){
		List<Profile> profiles = new ArrayList<Profile>();
		profiles.add(new Profile(1L,"Profile 1"));
		profiles.add(new Profile(2L,"Profile 2"));
		profiles.add(new Profile(3L,"Profile 3"));
		profiles.add(new Profile(4L,"Profile 4"));
		profiles.add(new Profile(5L,"Profile 5"));
		return profiles;
	}
	
	public User getUser() {
		return user;
	}
}

Dependent classes are :

public class Profile {
	Long id;
	String name;
	Long profileId;
	
	public Profile(){
		
	}

	public Profile(Long id, String name) {
		super();
		this.id = id;
		this.name = name;
	}


	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	
}

and

public class User {
	Long id;
	String name;
	Long profileId;
	public User(){
		
	}


	public User(Long id, String name) {
		super();
		this.id = id;
		this.name = name;
	}


	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public User(Long id, String name, Long profileId) {
		super();
		this.id = id;
		this.name = name;
		this.profileId = profileId;
	}


	public Long getProfileId() {
		return profileId;
	}


	public void setProfileId(Long profileId) {
		this.profileId = profileId;
	}
	
	
}

Then open the new.user.xhtml. The layout is broken


    
> h:selectOneMenu with f:selectItems layout problem
> -------------------------------------------------
>
>                 Key: RF-12546
>                 URL: https://issues.jboss.org/browse/RF-12546
>             Project: RichFaces
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: component-menu
>    Affects Versions: 4.2.3.Final
>         Environment: mac os 10.7, java 7, jboss tools
>            Reporter: olivier smadja
>            Priority: Critical
>         Attachments: Screen Shot 2012-10-21 at 9.08.01 AM.png
>
>
> I'm creating a simple 'new user' form with 3 fields : a textfield with the name , a combo with the list of profiles and a calendar.
> I use <h:panelGrid columns="2"> to layout the form with 2 columns. When the combo is built with h:selectOneMenu with f:selectItems (loading data dynamically from a list), the layout is broken : It seems the <h:selectOneMenu> creates extra content (before combo content) that breaks the 2 columns layout.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the richfaces-issues mailing list