aspose file tools*
The moose likes JSF and the fly likes Need inputTextArea functionality + escape= Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Need inputTextArea functionality + escape="false"" Watch "Need inputTextArea functionality + escape="false"" New topic
Author

Need inputTextArea functionality + escape="false"

Karl Krasnowsky
Ranch Hand

Joined: Jan 16, 2009
Posts: 97
Hello,
Would seem a pretty simple question but I've not found any option as yet to perform the functionality that's required.
In conjunction to using the richfaces a4j:push control I'm needing to update a text area on the form with log information that is refreshed on a set time interval.
I have a listener object that accepts strings of messages from a message server and upon time interval will (currently) update the contents of an inputTextArea with the current contents of the sum of the messages, essentially providing a realtime log reader service.
So I've set the inputTextArea to read only, set the size to a particular size so it contain a reasonable number of log messages and once/if the log extends the size of the area vertical scroll bar is dynamically generated to be able to scroll the additional messages. Currently it works very well.
Problem is, I would like to conditionally apply formatting to some of the lines to style (for example, on a warning message I'd like to set the background and font color to something that will differentiate from a normal informational message. The inputTextArea does not provide the ability to do this and the easiest description for what I'm wanting is an "outputTextArea" that will allow html/xml rendering so I can apply styles to the text accordingly.
There must be something relatively simple and straight forward to accomplish this, but I've been hunting for a few days now without a solution.

Any help/suggestions would certainly be appreciated.
Thanks!
Karl



[SCJP 6]
[SCBCD in process]
Ilari Moilanen
Ranch Hand

Joined: Apr 15, 2008
Posts: 198
If you are only outputting something with the input then you are on a right track when you want a "outputTextArea". But it is not needed in JSF since you can always use outputText. So why can't you use outputText? If you absolutely need the input to be actual html textarea you can just use plain html textarea and put the inputText inside it or something similar (like fake it with CSS)

EDIT: And after reading your text more carefully I think that what you try to accomplish is not possible. You want html textarea input where you can change some of the text to use different font and/or background color? I think that may be impossible since html textarea does not allow that. If it would be enough to change the style of the whole text then you would naturally apply the changes to the whole input (with style or class attribute). So I would stick with outputText and use CSS. Naturally there is something that does this in some third party JSF library somewhere but if you have already looked through richfaces and found none then I wouldn't try to include some second library if this is the only thing you need from it....
Karl Krasnowsky
Ranch Hand

Joined: Jan 16, 2009
Posts: 97
Ilari Moilanen wrote: And after reading your text more carefully I think that what you try to accomplish is not possible. You want html textarea input where you can change some of the text to use different font and/or background color? I think that may be impossible since html textarea does not allow that. If it would be enough to change the style of the whole text then you would naturally apply the changes to the whole input (with style or class attribute). So I would stick with outputText and use CSS. Naturally there is something that does this in some third party JSF library somewhere but if you have already looked through richfaces and found none then I wouldn't try to include some second library if this is the only thing you need from it....


Therein lies my frustration. For something so seemingly obvious I cannot find such a 3rd party control available. I'm thinking I may need to roll something myself, but this can't be such a novelty that it doesn't exist... however in the time that I'm taking looking for it I might as well write it myself.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15665
    
  15

There are several JSF controls that allow rich text editing. The RichFaces Editor component is one of them. They provide not only the raw input textarea with formatting, but the option to present various format controls as part of the assembly.

A lot like the message editor we use on the JavaRanch.


Customer surveys are for companies who didn't pay proper attention to begin with.
Karl Krasnowsky
Ranch Hand

Joined: Jan 16, 2009
Posts: 97
Tim Holloway wrote:There are several JSF controls that allow rich text editing. The RichFaces Editor component is one of them. They provide not only the raw input textarea with formatting, but the option to present various format controls as part of the assembly.

A lot like the message editor we use on the JavaRanch.


It's most likely my fault, but I'm fairly certain you don't understand my question. I can't make it any clearer, therefore, thanks but nevermind.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15665
    
  15

You limited yourself when you said "inputTextArea". You can do this sort of stuff with a scrollable html div and an outputTextArea with "escape="false"".

Or you can use an inputTextArea with "readonly="true".

What you aren't going to find is automatic removal of text once the buffer limit is reached. They all figure you want it removed, remove it yourself. According to whatever rules you see fit.

Which is (relatively) easy to do with either of the above solutions.

If you want something more record-oriented, use a dataTable with the model set up so that each row in the table is a line of text. However that one in its most basic form won't give you a scrollbat. There's a RichFaces Extended DataTable that will, however.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need inputTextArea functionality + escape="false"
 
Similar Threads
Save selected content of InputTextArea
inputTextArea
Dynamically populating an inputTextArea with the values being selected from the UI
Usage of inputTextarea in JSF
JSF inputTextarea