Results 1 to 10 of 10
  1. #1
    KamilBek is offline Member
    Join Date
    Oct 2009
    Posts
    6
    Rep Power
    0

    Default How to use <f:convertdatetime> or<s:convertdatetime> for date in message

    I have message with text and date. I want use date pattern for it and use <f:convertdatetime> but it used only when wrapper tag have only date as value. How to use my pattern?
    <h: outputText value="Today is #{bean.date}!!!">
    <f:convertdatetime pattern="dd.mm.yyyy"/>
    </h: outputText>
    don't work. How to solve it?
    Last edited by KamilBek; 10-23-2009 at 08:55 AM.

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Separate the text into two outPutText tags. One containing the text and the other the date value.

  3. #3
    KamilBek is offline Member
    Join Date
    Oct 2009
    Posts
    6
    Rep Power
    0

    Default

    Yes, it is solution, but it make 2 <span> element in HTML, but I want make 1 <span> element.

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Why do you want JSF to generate only 1? You shouldn't rely too much on those implementation details. They could change and leave your code no longer working.

  5. #5
    KamilBek is offline Member
    Join Date
    Oct 2009
    Posts
    6
    Rep Power
    0

    Default

    I put it into <h: panelGrid> (it make table) and when I put two span in one cell, every span take new line, but they must be in one line. I can do it with css styles, but I think that it is worse than relying to implimentation of jsf tags.
    Last edited by KamilBek; 10-26-2009 at 09:25 AM.

  6. #6
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Don't put the span at all. Just put them in a panelGrid with two columns and they will be on line.

  7. #7
    KamilBek is offline Member
    Join Date
    Oct 2009
    Posts
    6
    Rep Power
    0

    Default

    It must be in one cell of h: panelgrid.
    if I put in this cell tag like:
    <h: panelGrid>
    <h: outputText value="Today is ">
    <h: outputText value="#{bean.date}">
    <f:convertdatetime pattern="dd.mm.yyyy"/>
    </h: outputText>
    <h: outputText value="!!!">
    </h: panelGrid>

    At first it will be new table and I think It not very good, and Second I already use some CSS styles for wrapper h: panelGrid, wich make big distance between cells. And in this situation text does not look well.

  8. #8
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Did you read my response above?
    <h: panelGrid columns="2" ...

  9. #9
    KamilBek is offline Member
    Join Date
    Oct 2009
    Posts
    6
    Rep Power
    0

    Default

    Yes, sorry I wrote wrong text. I mean
    <h: panelGrid columns="3">
    <h: outputText value="Today is ">
    <h: outputText value="#{bean.date}">
    <f:convertdatetime pattern="dd.mm.yyyy"/>
    </h: outputText>
    <h: outputText value="!!!">
    </h: panelGrid>

    but result is same

  10. #10
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    You mean that code displays everything on its own line? Did you refresh/redeploy/restart?
    They should all appear on the same line.

    If all fails put all of them into a panelGroup.

Similar Threads

  1. java.util.Date vs java.sql.Date
    By Jack in forum New To Java
    Replies: 5
    Last Post: 10-28-2010, 03:59 PM
  2. problem with <s:convertDateTime>
    By raj18 in forum Advanced Java
    Replies: 2
    Last Post: 10-02-2009, 09:56 AM
  3. Compare date input to database with current date
    By hungleon88 in forum Advanced Java
    Replies: 2
    Last Post: 11-25-2008, 09:10 AM
  4. Creating a Gregorian Calendar using a Date object gives date - 1
    By prachi_goliwadekar in forum New To Java
    Replies: 1
    Last Post: 05-08-2008, 09:32 PM
  5. Difference between current date and anothe date
    By vijay balusamy in forum New To Java
    Replies: 1
    Last Post: 04-16-2008, 05:15 PM

Tags for this Thread

Posting Permissions

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