Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. public class Example {
  2.  
  3. private List<ExampleObject> listExampleObject;
  4.  
  5. //Get and set from list...
  6. }
  7.  
  8. public class ExampleObject extends ExampleObjectExtend {
  9.  
  10. private String exampleAttribute;
  11.  
  12. //Get and set from attribute.
  13.  
  14. }
  15.  
  16. public class ExampleObjectExtend {
  17.  
  18. private String extendedAttribute;
  19.  
  20. //Get and set from extendedAttribute..
  21.  
  22. }
  23.  
  24. <h:selectOneMenu id="listExample">
  25. <f:selectItems value="#{myBean.listExampleObject}" var="example" itemValue="#{example.extendedAttribute}" itemLabel="#{example.exampleAttribute}"/>
  26. </h:selectOneMenu>
  27.  
  28. <h:selectOneMenu id="listExample">
  29. <f:selectItems value="#{myBean.ddl_example_options}"/>
  30. </h:selectOneMenu>
  31.  
  32. public class MyBean implements Serializable{
  33.  
  34. List<SelectItem> ddl_example_options;
  35. String ddl_example;
  36.  
  37. public List<SelectItem> getDdl_example_options() {
  38. return ddl_example_options;
  39. }
  40.  
  41. public void setDdl_example_options(List<SelectItem> ddl_example_options) {
  42. this.ddl_example_options = ddl_example_options;
  43. }
  44.  
  45. public String getDdl_example() {
  46. return ddl_example;
  47. }
  48.  
  49. public void setDdl_example(String ddl_example) {
  50. this.ddl_example = ddl_example;
  51. }
  52.  
  53. private void setDdl_example(){
  54. ddl_example_options=new ArrayList<>();
  55. ddl_example_options.add(new SelectItem("1","Option-1"));
  56. ddl_example_options.add(new SelectItem("2","Option-2"));
  57. }
  58.  
  59. @PostConstruct
  60. public void init(){
  61. setDdl_example();
  62. }
  63. public MyBean() {
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement