Reputation: 81
I want to put a date that is coming back from my database into the title attribute of my tab. The issue i am having is that it is coming back from the database in a very ugly way;
Friday Oct 04 00:00:00 GMT 2013
Now i can easily format this when i put it inside of an output text tag like so;
<h:outputText style="color:red;" value="#{email.emailDate}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
And this gives out exactly how i want to put it, but i'm not able to put the output text tag within the title attribute of my p:tab>
<p:tab title="#{email.headline} #{submissionDate}" titleStyleClass="email-header">
I have tried making the date coming back a variable and then formatting it there but it doesn't seem to recognize me wanting to format it and it still comes back in ugly mode but my syntax is most likely wrong;
<ui:param name="submissionDate" value="#{email.emailDate}">
<f:convertDateTime value="#{email.emailDate}" pattern="dd/MM/yyyy" type="date" />
</ui:param>
Any advice on formatting it on the front end rather then having to change it in the managedBean?
Upvotes: 2
Views: 979
Reputation: 43013
With Omnifaces, you can achieve what you look for. See sample code below:
<c:set var="emailDate"
value="#{of:formatDate(email.emailDate, 'dd/MM/yyyy')}" />
<h:outputText title="#{emailDate}" value="#{emailDate}" />
...
<span title="31/01/2014">31/01/2014</span>
...
Upvotes: 4