Textarea problem

hy, people!here�s my question:I am developing a web application using apache struts.I am using the JSLT tags from struts, including <html:textarea>.But here�s the thing:when I get in the action the content of the textarea inside a string object, it comes in a single line of string I think, because if I use the bean:write tag to print It comes the hole text in a big single line(and I have to use ben:write to display the content of the textarea, can�t be avoided),so my question is:how I can make the string of the textarea to comes with the original break lines of the text when the user input in the textarea??

Hi,
This is not a problem with the textarea. Instead, when browser render out the page it will ignore all carriage returns. You need to replace carriage returns with <br> tags
As of struts 1.1, the <bean:write> tag has no option to replace carriage return for you. What you can do is
1) Replace all "\n" with "<br>" in your string. You can do this in your code value = value.replaceAll("\n","<br>"); Set filter to false in <bean:write ..... filter="false"/>
or
2) Create your own WriteTag class that extends from the Struts WriteTag class and overwrite the doStartTag() method. Include the replaceAll code inside the doStartTag().
Hope this helps

Similar Messages

  • Appending  a list in a textarea problem

    Hi im new too java as you will probably guess from my problem but anyway. Im writing an application that needs to output a dynamic list to textarea that is affected by buttons that increase and decrease the number of items next to the item in question. if the item has 0 selected it should not be displayed.
    iv tried setCaretPosition, replacerange and append but cant get it to work. I think the ieal solution would be if i could set the caret with an x,y coordinate but i dont even know if this is possible, any help would be greatly appreciated and im sorry if the explanation waffle on but im really annoyed with it

    I can not figure out what you want.
    Are you trying to change the caret postion or the contents of the text area? what do you mean by items next to the item in question? And what does the x,y position have to do with the text you want to add/delete?

  • TEXTAREA problem in IE...

    Hi All,
    We are using Internet Explorer version 6.0.2800.1106 on Windows 2000 Professional SP4.
    Our JSP page has around 50 TextArea components in form. And each TextArea component has around
    150 bytes of data entered. When we try to submit the page it gives Error prompt "A runtime error has occurred . Do you want to debug ?... Invalid Syntax. " . Any idea about this problem and how to resolve it ? IS there any restrictions on the TextArea componenet size in IE ? Same page works fine with Mozilla FireFox browser.
    Regards,
    Ronak

    Is your HTML formatted properly? there's no data size, in particular, for textarea. Is that error a Javascript error or the browser crashing?

  • Textarea problem with jsp

    How can i set the value of a textarea retrieved from a MySQL database?
    I tried using this but didn't work:
    <textarea rows="5" cols="40" name="description" value="<%=ei_res1.getString("description")%>"></textarea>
    After this code is run, the value is seen in the source but not seen in the textarea itself.
    Thanks
    Anzel

    Realize esta JSP y la probe funciona, la soluci�n a tu problema es similar a esto...
    <html>
    <BODY>
    <%@ page language="java" buffer="16k"%>
    <%! String test=new String("5"); %>
    <textarea rows="5" cols="40" name="description" value="<%=test %>">
    </textarea>
    </BODY>
    </html>
    ------tu problema, solucionado -----
    <textarea rows="5" cols="40" name="description" value="<%=ei_res1.getString("description")%>">
    </textarea>

  • Textarea problem when sending mail (only Firefox)

    When sending mail using textarea item with multiple lines, carriage returns are taken away in resulting mail when sent in Firefox, but not in IE.
    To send mail, I call Javascript function that gets textarea value ($v or $x.innerHTML give the same result) and calls then on-demand process that calls in turn APEX_MAIL function.
    Igor

    Thank you, Jari!
    "pre" did the trick. Line breaks are OK now.
    There is one small inconvenience, though: font becomes Courrier instead of sans-serif type. But this is less disturbing than missing line breaks.
    Igor

  • textarea /textarea problem!

    Hi! This might seem simple enough
    but I can't seem to figure it out:
    I have written a form in a jsp-page.
    In the there are a couple of fields
    and a textarea, i'm using the method
    post. The thing is that when i process
    the form-input all the carriage returns
    in the textarea has vanished and the
    text is displayed as if it were
    written in one single row.
    Why is this
    and how can it be fixed?
    /Andreas

    Hi ,
    try this...........
    write a javascript method................
    in the below method 'specialProvision' is the textarea name....
    function formatText(){
         var frm = document.forms[0];
         var temp="";
         var i=0;
         var spProv = frm.specialProvision.value;
         while(spProv.indexOf("\n")!=-1){
              i=spProv.indexOf("\n");
              temp += spProv.slice(0,i-1);
              temp += "|||";
              spProv = spProv.slice(i+1,spProv.length)
         temp += spProv;
         frm.spProv.value =temp;
    while sending it to the database say in in the save method....
    function save(){
    formatText();
    document.forms[0].action = 'here your target path may be to a servlet';
    document.forms[0].submit();
    and while showing in the textarea use this method.................
    showText('here your textarea value ie in the database');
    // the text area value will be stored with ||| in between .....in the database....
    function showText(val){
         while(val.indexOf("|||")!=-1){
              val = val.replace("|||","\n");
         return val;
    and from the above method it will show as it is you typed into the textarea...............
    if you still have pbs contact me at : [email protected]
    Thank you
    Ravikiran

  • LookAndFeel TextArea Problem

    I've been creating custom LookAndFeel classes and everything appears
    fine except for one problem... After I enter some text into a JTextArea
    (when using a custom LookAndFeel), I cannot delete characters or use
    the Backspace key to remove characters. After I switch back to Motif
    or the default Windows LookAndFeel, I am able to delete characters and
    use the backspace key as it was meant to be used.
    Haven't found any info regarding this problem. Has anyone had this
    problem previously, or does anyone have a possible solution?

    As luck would have it, just after I post a question, I find a
    solution to my own problem.
    Instead of extending BasicLookAndFeel, I extended
    MotifLookAndFeel.

  • JOptionPane/TextArea problem

    I need to get the string value from a JOptionPane and store it into a AWT TextArea.
         // Button Input
         public void actionPerformed(ActionEvent e)
              String str = e.getActionCommand();
              if (str.equals("Click Me"))
                   String inputValue = JOptionPane.showInputDialog("Please input a value");
                   txtOutput.setText(inputValue);
         }When I click OK on the JOptionPane, a NullPointerException occurs with additional text: "Exception in thread "AWT-EventQueue-1"". The text isn't added onto the text area. What am I doing wrong?

    did you declare and initalize the txtOutput variable?
    NullPointerException sometimes occur when you are trying to use operations on a null object.

  • SImple TextArea problem.

    I am getting back into Java after working in C++ for a long while so I am very rusty.
    I need my jTextArea to resize when when the jDialog resizing
    The jDialog uses a Gridbag layout with two cells
    The first cell has a jTextArea and the second contains a panel with two buttons.
    I have the jTextArea set to fill the cell vertically and horizontally and set the anchor to NorthWest.
    Any suggestions on what to try?

    Use a BorderLayout. Add the JScrollPane containing the JTextArea to the "CENTER" and then add your other panel to some other area in the BorderLayout.
    Read the Swing tutorial on [Using Layout Managers|http://java.sun.com/docs/books/tutorial/uiswing/TOC.html].

  • Relative Resizing issues

    Hi I started with java a few weeks back and I am really getting into using swing to make my problems.
    I've got the hang of GUIs for the most part but I've been having difficulty with the TextAreas and the sizing of panels
    1) My TextArea problem:
    When the user writes into the TextArea and the text becomes wider than the textfield's specified size, the textarea gets wider, rather than the words wrapping onto the next line as I would like. Additionly when the Tab key is pressed, a tab is inserted into the text, rather than the cursor moving to the next text field (as I would like)
    2) My panel size problem
    I have been using the GridBagLayout for the layout of my GUIs and it works great except my panels size themselves to the objects inside them, and the objects inside them change size quite often, this means the wondow is constantly resizing itself. Is there any way of making the panels fixed at a certain size?
    3) One other thing that came up is can you make a window un-resizable so that users can't maximise and minimise it?
    I know these problems seem a bit basic but I have looked around and I think they are just overlooked as "too obvious" by most people!!
    Thanks
    James

    Read the docs, most of this stuff is well commented in the swing API javaDocs.
    1) setLineWrap()
    2) don't pack() your Frame, instead set it to a size larger enough for your components. That way if the components resize, the frame won't. This is not a clean solution BTW
    3) setResizable(), setUndecorated();
    have fun using swing to SOLVE your problems

  • Encoding HTML for use in forms

    This is probably a dumb question and is something I've probably overlooked in the API's, but before I write a huge block of code to deal with the problem, I thought I'd ask here first:
    I'm wrinting a form to add/edit records in a database. Is there an easy way to encode what a value to be inserted into a HTML document? e.g.
    <INPUT NAME="title" VALUE="[value to be inserted goes here]" />The actual pasing/insertion has already been coded, but the problem I have is I need something to encode the value before it is inserted. Why? If the value contains quotes, it will break the tag e.g.
    <INPUT NAME="title" VALUE="A value with "quotes" will break this tag" />In addition to this, in some cases I need to encode all HTML special characters ( <tag> to >tag< ) so that the following does not occur:
    <TEXTAREA NAME="post">
    You would think that it's safe to put anything in this block,
    but if some crafty bugger enters </TEXTAREA> in this field in the database,
    there's gonna be trouble...
    </TEXTAREA>And if I encode these tags I will, of course, need some way of decoding the tags too...
    This isn't too difficult a task, but I really don't want to write code to do this if it's already somewhere in the API since there's bound to be some oversights I havn't considered and blah blah blah. So is it in there?
    *** interesting note - this forum could do with something that deals with the </TEXTAREA> problem - I previewed this post and when I came back to edit it, the </TEXTAREA> tag broke the form. Typical...

    URLEncoder.encode() was what I looked at first - since it is designed for use with URL's (hence the name) it has several big drawbacks, formost of which is that all spaces are converted to "+" signs. Not good at all...
    As I originally said, what I require is a little more complex, and I was initially surprised at how little support there is in the API considering Java has such strong tie-ins with internet-related tech (especially with the recent popularity of servlets and JSP).
    Here is a brief example: in the database there is a record of a post, much like the forum posts you see here. The post has a title, and in this title the poster has thoughtfully included an ampersand(&):
    This is the title of my post & I think it's gonna give the Kid some headachesNaturally, I wanna encode the ampersand to &amp; Preferrably when the post is originally made. This is no big deal. What gets inserted into the database will be:
    This is the title of my post & I think it's gonna give the Kid some headachesSay at some point in the future the post will be edited, in the editing screen html there will be something like:
    title:<INPUT NAME="title" VALUE="This is the title of my post & I think it's gonna give the Kid some headaches" /><BR />Now, if you view that snippet of code in a browser, what you will see is an input box containing the text:
    This is the title of my post & I think it's gonna give the Kid some headachesSo I guess the string must be encoded again before it is inserted in the VALUE="" of the the INPUT tag. Also, not a big deal (though I have to remember not to encode the string when it is not being used in an input tag - otherwise it will ALWAYS be displayed as &amp;)
    A side note is that other ampersand escaped characters get screwed up when encoding them twice i.e &quote; ends up getting saved as &amp;quote;, which is something that I don't want. The code to get around this is simple, but I resent having to write it as I see it as being an essential method when outputting html and should, in my opinion, be included somewhere in the API.
    Anyway, that has already been done and works fine. Now I'm working on parsing the passed post so that only the <tags> that I want to be allowed are left unchanged, and the rest of the &lt;tags&gt; are encoded (including the dreaded </TEXTAREA>). There's precious little hope that there's anything out there that will do this for me, but it was worth asking before I started...
    Cheers for your interest.
    Note: writing this post has been a king-sized pain in the arse since I had to make sure all the &'s were written as &amp; and all the &amp; written as &amp;amp; - nightmarish.

  • HtmlText & XML.prettyPrinting/ignoreWhitespace issue

    i have a module that has a tree component, a advanceddatagrid and a textarea.
    you select an item from the tree to populate the advanceddatagrid and then you select an item from the advanceddatagrid to populate the textarea.
    problem:
    the textarea uses htmlText (which is stored in a table on the DB), but for it to display correctly, I need to set XML.prettyPrinting = false and XML.ignoreWhitespace = false.  But then, the tree and advanceddatagrid look at weird with empty nodes (that didnt exist before).
    so im stuck with either having my text look correctly in my textarea or having the tree and advanceddatagrid look correct...there must be something im doing wrong.
    any help would be awesome!
    thanks

    I'd run a trace on your first node to make sure you're
    getting your XML pull correct first. Also, I generally keep my
    .ignoreWhiteSpace = "true" because that helps solve some problems.
    Last, I really try to shy away from defining text fields
    using a field variable. Rather I assign it using
    textFieldName.text = "something something something"
    That way, the variable field can be used if I need to play
    with those values later on. Run the trace() stuff and tell me what
    you get.

  • Problem with HTML in a read only textarea item

    I'm working on a messaging system for our site. For the body of the message, we use a standard textarea item. However, if we come to the messaging page from a certain page in our system, then we pre-load the textarea item, and make it read only. The only problem with this is that there are HTML tags in the body that we try to pre-load. This is causing problems because they aren't being interpreted as tags, but are being displayed as text. If I make the textarea editable, then everything looks fine, it's just when I set the area to be read only that it doesn't work. Any thoughts on how to fix this? Thanks!

    Not always. A user is allowed to edit that area in most circumstances except for when the user arrives at the page coming from 1 page in particular. In this case, then the field is read-only. At all other times though, it is editable.
    As a workaround, whenever I know I'm coming from this page, I set a variable, and if the variable is set, then I use a Display Only item and then hide the Textarea. If the variable is not set, then I hide my Display Only item and show the Textarea. Not very elegant, but it works.

  • HTML input textarea causes problems

    Hi,
    I have a textarea on my form where the user will have the opportunity to enter a paragraph of text, where he can use HTML tags and whatever. But as soon as I enter html tags into this area, the formfileds coming after this textarea cannot sent their parameters to the next procedure. No html tags, everything works fine.
    Any idea?

    Hi Nilay,
    I don't think the textarea has anything to do with your problem. I just tried out and it works fine for me (at least with the italic and strong tags). Could you provide some more information on your case? (HTML source, the way you process the parameters, etc.)
    Peter

  • Problems with displaying the contents in a TextArea in Swing?

    Hi All,
    In my project i am getting the contents of a .txt file from the server machine and i want to display it in a TextArea in Swing.
    I have done that without any problem.But the contents from a .txt file that are displayed in a TextArea is not aligned property but when i print it in the console it looks ok.But when it is displayed in the
    TextArea it is not aligned properly.
    Plz. do provide a solution regarding this.
    Thanx,
    m.ananthu

    Hi Camick,
    Thanks man it looks neat and the alignment is good.
    Thanx,
    m.ananthu

Maybe you are looking for