0

Is there any way to make a conditional formatting with convertNumber ? i have a Table - one colomn displays a timespan in days. the problem: it shows like

  • 5 days
  • 3 days
  • 2 days
  • 1 days

but i want it to show "1 day"

I am using this code

<h:column>
   <f:facet name="header"><h:outputText value="Timespan" /></f:facet>
   <h:outputText value="#{bean.days}">
       <f:convertNumber pattern="0.## days" />
   </h:outputText>
</h:column>

on an other part of the Application I use POI to export to an Excel Sheet. there i set a cell format that accomplishes that need

CellStyle dayStyle = wb.createCellStyle();
dayStyle.setDataFormat(format.getFormat("[=1]General \"day\";General \"days\""));

is there any way to do the same with jsf? i don't want to make it something like this:

<h:column>
   <f:facet name="header"><h:outputText value="Timespan" /></f:facet>
   <h:outputText value="#{bean.days}" rendered="#{bean.days != 1}">
       <f:convertNumber pattern="0.## days" />
   </h:outputText>
   <h:outputText value="#{bean.days}" rendered="bean.days == 1" value="1 day" />
</h:column>

Thanks in advance

Xaw4
  • 176
  • 2
  • 9
  • For a task this specific, you can always implement your own subclass. – SJuan76 Jun 24 '13 at 11:08
  • Custom converter, or even define a JSP function (was looking for the link to a previous answer, but I am not finding it). – SJuan76 Jun 24 '13 at 11:22
  • Use a custom converter. – Vrushank Jun 24 '13 at 11:27
  • This problem has exactly the same grounds as asked and answered here: http://stackoverflow.com/questions/7122460/jsf-convertdatetime-with-timezone-in-datatable/ – BalusC Jun 24 '13 at 11:41
  • I used a custom Converter, like mensioned in the answer of http://stackoverflow.com/questions/7122460/jsf-convertdatetime-with-timezone-in-datatable/ – Xaw4 Jul 05 '13 at 11:23

0 Answers0