• Post Reply Bookmark Topic Watch Topic
  • New Topic

outputFormat substringing

 
Chad Foor
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a situation where I have a ResultSet being built by an acionlistener from a commandbutton on my JSF form and am trying to
display this on a <h:dataTable>

I can render the results just fine, however what I'd like to do is to show only the first 50 odd characters of one of the fields in the result set. Like this:

...

<h:dataTable value="#{form.myResults}" var="rstPtr"
rendered="#{form.renderMyTable}">
<h:column>
<%--
facet / header stuff here...
--%>
...
<hutputText value="#{rstPtr.Title}"/>
</h:column>

<h:column>
<%--
facet / header stuff here...
--%>
<hutputFormat value="{0, ... }" >
<f:parameter value="#{rstPtr.Description}/>
</hutputFormat>

</h:column>
... (and so on) ...

</h:dataTable>


I've seen numerous examples how one would tweak the date / number formatting for the value attribute in the outputFormat tag, but I've
yet to see a good example of substringing the value I'm stashing in <f:parameter> here. (Although I've seen several authors allude to the
possiblity, just nothing concrete.)

Like I said, all I'd like to do is show the first 50 characters. The database that I'm sending the query to could potentially send me much larger string data for this field.

Appreciate any suggestions.

Thanks,
Chad
 
Chad Foor
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind, I figured it out. Basically just built my own custom converter class and registered it within faces-config.xml.

Didnt need to use <hutputFormat> tag, just straight up <hutputText>
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!