0 Replies Latest reply on Sep 9, 2009 8:55 AM by Roy Abu Bakar

    Dynamically display a random text from database

    Roy Abu Bakar Newbie


      How to dynamically display a random text from database?

      I had a page that will be display a wise word quote selected from database with rich:effect, the message now displayed if i put a static message.

      this is my home.xhtml:

             <div class="billboard-home">
                      <blockquote id="blockquote" style="display:none" cite="#"><span id="quote">&#8220; <h:outputText value="#{wiseWordHome.instance.quote}" /> .&#8221;</span><br /><br /><span id="author">&#8212;<h:outputText value="#{wiseWordHome.instance.author}" /></span>
              <rich:effect name="showDiv" for="blockquote" type="Appear" params="delay:1.8, duration:0.5"></rich:effect>
              <rich:effect name="hideDiv" for="blockquote" type="Fade" params="delay:8.0, duration:2.0"></rich:effect>
                      <rich:effect for="window" event="onload" type="Appear" params="targetId:'blockquote',delay:1.8, duration:0.5" />
                      <rich:effect for="window" event="onload" type="Fade" params="targetId:'blockquote',delay:7.0, duration:1.0" />
                      <a4j:poll id="quotesPoll" interval="10000" enabled="true" oncomplete="hideDiv();showDiv();" ignoreDupResponses="true" eventsQueue="quotesQueue"></a4j:poll>

      and this is my bean WiseWord.java

      @Table(name = "wise_word")
      public class WiseWord implements java.io.Serializable {
              private Integer id;
              private String quote;
              private String author;
              public WiseWord() {
              public WiseWord(String quote, String author) {
                      this.quote = quote;
                      this.author = author;
              @GeneratedValue(strategy = IDENTITY)
              @Column(name = "id", unique = true, nullable = false)
              public Integer getId() {
                      return this.id;
              public void setId(Integer id) {
                      this.id = id;
              @Column(name = "quote", length = 65535)
              @Length(max = 65535)
              public String getQuote() {
                      return this.quote;
              public void setQuote(String quote) {
                      this.quote = quote;
              @Column(name = "author", length = 50)
              @Length(max = 50)
              public String getAuthor() {
                      return this.author;
              public void setAuthor(String author) {
                      this.author = author;

      Please help me. Thanks.