SelectOneMenu grouping height issues?

UI Components for JSF
Post Reply
shinsuke
Posts: 2
Joined: 19 May 2014, 02:57

18 May 2015, 10:54

version PF5.2

5 groups (totoal item 100) SelectOneMenu is height: auto.
Is this a specification? Or issues?

Code: Select all

<h:body>
  <h:form id="form">
    <p:selectOneMenu>
      <f:selectItem itemLabel="height:200" />
      <f:selectItems value="#{backingBean.nogroup}"/>
    </p:selectOneMenu>
    <p:selectOneMenu>
      <f:selectItem itemLabel="height:auto" />
      <f:selectItems value="#{backingBean.group5}"/>
    </p:selectOneMenu>
    <p:selectOneMenu>
      <f:selectItem itemLabel="height:200" />
      <f:selectItems value="#{backingBean.group12}"/>
    </p:selectOneMenu>
  </h:form>
</h:body>

Code: Select all

package selectonemenugroup;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.faces.model.SelectItem;
import javax.faces.model.SelectItemGroup;
import javax.inject.Named;

@Named
@RequestScoped
public class BackingBean {
  private List<SelectItem> nogroup; // size 100
  private List<SelectItem> group5; // size 5. SelectItemGroup inner SelectItem size 100
  private List<SelectItem> group12; // size 12. SelectItemGroup inner SelectItem size 96
  
  public List<SelectItem> getNogroup() {
    return nogroup;
  }
  public List<SelectItem> getGroup5() {
    return group5;
  }
  public List<SelectItem> getGroup12() {
    return group12;
  }
  
  @PostConstruct
  void postConstruct() {
    nogroup = IntStream.range(0, 100)
      .mapToObj(i -> new SelectItem(String.valueOf(i), "item" + i))
      .collect(Collectors.toList());
    
    group5 = IntStream.range(0, 5)
      .mapToObj(gi -> {
        final String groupLabel = "group" + gi;
        SelectItemGroup group = new SelectItemGroup(groupLabel);
        group.setSelectItems(IntStream.range(0, 20)
          .mapToObj(i -> new SelectItem(groupLabel + i, groupLabel + "-" + i))
          .toArray(SelectItem[]::new));
        return group;
      })
      .collect(Collectors.toList());
    
    group12 = IntStream.range(0, 12)
      .mapToObj(gi -> {
        final String groupLabel = "group" + gi;
        SelectItemGroup group = new SelectItemGroup(groupLabel);
        group.setSelectItems(IntStream.range(0, 8)
          .mapToObj(i -> new SelectItem(groupLabel + i, groupLabel + "-" + i))
          .toArray(SelectItem[]::new));
        return group;
      })
      .collect(Collectors.toList());
  }
}
output HTML

Code: Select all

...
<div class="ui-selectonemenu-items-wrapper" style="height: 200px;">...</div>
<div class="ui-selectonemenu-items-wrapper" style="height: auto;">...</div>
<div class="ui-selectonemenu-items-wrapper" style="height: 200px;">...</div>
...

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: tandraschko and 40 guests