• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

how to set the length of a string

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I am trying to set the length of a string when it is shown inside a panel this way:

<p:panel header="m">
<div id='content'>
<p> <h:outputText value="#{Content.load}" styleClass="element"/></p>
</div>
</p:panel>

then in the .css file (styleClass="element") I´ve set the width value, this is a bizarre way of course it doesn´t works, my .css is:

.element{width: 20px;}

¿Any idea?

Thanks

 
Saloon Keeper
Posts: 25477
180
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like I mentioned in another answer, HTML isn't a strict character-based definition language. Not only does it ignore newlines, it will remove multiple spaces when it displays a page.

A popular way of getting around this is to fake it using the "non-break space" entity ("&nbsp;"), but that's brute force.

On the other hand, you can't set width on an outputText JSF tag, because the outputText generates an HTML <span>, which doesn't support width. So what you have to do is embed the outputText in a construct that does support widths, such as a column in a table. Or, in the case that you used, a panelGrid will do:



Note that I got rid of the raw HTML tags. They're not good practice and they weren't needed anyway. I also changed the capitalization on your bean name, since as a instance variable, it should begin with an uppercase letter. That should only be done for class names.
 
Screaming fools! It's nothing more than a tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic