Results 1 to 7 of 7
  1. #1
    kaghamdi is offline Member
    Join Date
    Sep 2010
    Posts
    3
    Rep Power
    0

    Default can't make ui:repeat work

    Hello

    I have a web app with ui:repeat and h:dataTable tags. the repeat tag does not work while dataTable works. what did I do wrong in here. see code below

    My index.xhtml has the following contens:

    = Start ============================


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"<br/> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml"<br/> xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">


    <h1>Repeat Tag</h1>
    <ul>
    <ui:repeat var="color1" value="#{colorsBean.colors}">
    <li>#{color1}</li>
    </ui:repeat>
    </ul>

    <hr/>

    <h1>DataTable Tag</h1>
    <ul>
    <h:dataTable var="color2" value="#{colorsBean.colors}">
    <h:column>
    <f:facet name="header">
    <h:outputText value="Color" />
    </f:facet>
    <h:outputText value="#{color2}"/>
    </h:column>
    </h:dataTable>
    </ul>
    </html>

    = End ============================



    ColorsBean is as follows:

    == Start ===========================
    public class ColorsBean {
    String []colors = new String[] {"White","Black","Freen","Blue","Red","Yellow","Cy an"};

    public String[] getColors() {
    return colors;
    }

    public void setColors(String[] colors) {
    this.colors = colors;
    }
    }

    = End ============================

    the libraries I have under WEB-INF/lib are:
    - jsf-api.jar
    - jsf-facelets-1.1.11.jar
    - jsf-impl.jar

    ==============================

    here is the page output:

    Repeat Tag
    --------------------------------------------------------------------------------
    DataTable Tag

    Color
    White
    Black
    Freen
    Blue
    Red
    Yellow
    Cyan

  2. #2
    kaghamdi is offline Member
    Join Date
    Sep 2010
    Posts
    3
    Rep Power
    0

    Default

    sorry... post should be placed in Java Server Faces

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by kaghamdi View Post
    sorry... post should be placed in Java Server Faces
    Then post it again. Contact one of our moderators and they'll move it for you to the correct location.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  6. #6
    usamagdy is offline Member
    Join Date
    Oct 2010
    Posts
    5
    Rep Power
    0

    Default Solution

    Dear Brother you can simply use

    List<String> colors=new ArrayList<String>();
    it's working with me

  7. #7
    madnaelo is offline Member
    Join Date
    Dec 2010
    Posts
    8
    Rep Power
    0

    Default

    Its working perfectly, by a slight change in your code. Declare colorbean class as managed bean.

    I am not sure whether this is the issue exactly at your side, but please try and let me know did that help?
    Last edited by madnaelo; 12-31-2010 at 12:47 PM.

Similar Threads

  1. Make it work !
    By PhQ in forum New To Java
    Replies: 6
    Last Post: 09-20-2010, 09:22 AM
  2. How do i make this work What am i doing Wrong.
    By Ramaan in forum New To Java
    Replies: 2
    Last Post: 03-02-2010, 12:36 AM
  3. Make the Button Work
    By ŖΫ ỏ Ңόρę in forum New To Java
    Replies: 1
    Last Post: 02-27-2010, 11:52 AM
  4. Can't make JTable work -- please help!!
    By cagalli83 in forum Advanced Java
    Replies: 0
    Last Post: 02-13-2008, 10:31 AM
  5. To make work DLL from webservices
    By Felissa in forum Advanced Java
    Replies: 1
    Last Post: 07-05-2007, 08:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •