You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Harland <dh...@ufi.com> on 2007/05/17 11:57:55 UTC

newline being ignored

I have an object with String variable body. In the body is a newline
character then some text. When this is being posted the newline seems to
be being trimmed is there any way to stop this please?

______________________________________________________________________
Ufi Limited 
Registered in England No.  3980770 
Registered Office:  Dearing House, 1 Young Street, Sheffield, S1 4UP 

learndirect Solutions Ltd 
Registered in England No. 5081669 
Registered Office:  Dearing House, 1 Young Street, Sheffield, S1 4UP 

UFI Charitable Trust 
Registered in England No.  3658378 
Registered Charity No.  1081028 
Registered Office:  Dearing House, 1 Young Street, Sheffield, S1 4UP 

This email has been scanned by the MessageLabs Email Security System.

______________________________________________________________________

Re: newline being ignored

Posted by Antonio Petrelli <an...@gmail.com>.
2007/5/17, David Harland <dh...@ufi.com>:
>
> I am doing the following validation. Middle newlines and newlines at the
> end are preserved but newlines at the beginning are vanishing. I can see
> the newline at the beginning being returned from the db and hibernate
> but they disappear when displayed in the jsp.



It seems like a bug in JSP tag.
Just to be sure, see if the HTML page is created correctly: if the value
contains a newline, it could be a browser bug; it the newline is not there,
it is possibly a JSP tag bug.
Try to create a small test case (without db), just a post and display in a
text area.
If it does not work, then it's probably a bug.

Antonio

RE: newline being ignored

Posted by David Harland <dh...@ufi.com>.
I am doing the following validation. Middle newlines and newlines at the
end are preserved but newlines at the beginning are vanishing. I can see
the newline at the beginning being returned from the db and hibernate
but they disappear when displayed in the jsp.        

<field-validator type="requiredstring">
            <param name="trim">false</param>
            <message>body is required</message>
        </field-validator>
        <field-validator type="stringlength">
            <param name="minLength">1</param>
            <param name="maxLength">512</param>
            <message>body length must be between 1 and 512</message>
        </field-validator> 

-----Original Message-----
From: Antonio Petrelli [mailto:antonio.petrelli@gmail.com] 
Sent: 17 May 2007 11:22
To: Struts Users Mailing List
Subject: Re: newline being ignored

2007/5/17, David Harland <dh...@ufi.com>:
>
> I have a jsp with a textarea whose name is body. The text contained in

> body is newline then some text. The form is then posted to an action 
> that then writes it away to the database. If I then go back to view 
> the same page the newlline character has been removed. The text is 
> being trimmed by struts before it is displayed in the textarea.



Curious. What if the newline is in the middle of the text? does it
behave correctly?

Antonio


- ------
ML {UFI}

______________________________________________________________________
Ufi Limited 
Registered in England No.  3980770 
Registered Office:  Dearing House, 1 Young Street, Sheffield, S1 4UP 

learndirect Solutions Ltd 
Registered in England No. 5081669 
Registered Office:  Dearing House, 1 Young Street, Sheffield, S1 4UP 

UFI Charitable Trust 
Registered in England No.  3658378 
Registered Charity No.  1081028 
Registered Office:  Dearing House, 1 Young Street, Sheffield, S1 4UP 

This email has been scanned by the MessageLabs Email Security System.

______________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: newline being ignored

Posted by Antonio Petrelli <an...@gmail.com>.
2007/5/17, David Harland <dh...@ufi.com>:
>
> I have a jsp with a textarea whose name is body. The text contained in
> body is newline then some text. The form is then posted to an action
> that then writes it away to the database. If I then go back to view the
> same page the newlline character has been removed. The text is being
> trimmed by struts before it is displayed in the textarea.



Curious. What if the newline is in the middle of the text? does it behave
correctly?

Antonio

RE: newline being ignored

Posted by David Harland <dh...@ufi.com>.
I am using struts 2. I have the following class
<code>
public class test1 {

private String body;

public void setBody(String body){
	this.body = body;
} 

public String getBody(){
	return body;
}

}
</code>

I have a jsp with a textarea whose name is body. The text contained in
body is newline then some text. The form is then posted to an action
that then writes it away to the database. If I then go back to view the
same page the newlline character has been removed. The text is being
trimmed by struts before it is displayed in the textarea.

-----Original Message-----
From: Antonio Petrelli [mailto:antonio.petrelli@gmail.com] 
Sent: 17 May 2007 11:00
To: Struts Users Mailing List
Subject: Re: newline being ignored

2007/5/17, David Harland <dh...@ufi.com>:
> I have an object with String variable body. In the body is a newline 
> character then some text. When this is being posted the newline seems 
> to be being trimmed is there any way to stop this please?

Posted? Where?
And what are you using? Struts 1 or Struts 2?

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


- ------
ML {UFI}

______________________________________________________________________
Ufi Limited 
Registered in England No.  3980770 
Registered Office:  Dearing House, 1 Young Street, Sheffield, S1 4UP 

learndirect Solutions Ltd 
Registered in England No. 5081669 
Registered Office:  Dearing House, 1 Young Street, Sheffield, S1 4UP 

UFI Charitable Trust 
Registered in England No.  3658378 
Registered Charity No.  1081028 
Registered Office:  Dearing House, 1 Young Street, Sheffield, S1 4UP 

This email has been scanned by the MessageLabs Email Security System.

______________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: newline being ignored

Posted by Antonio Petrelli <an...@gmail.com>.
2007/5/17, David Harland <dh...@ufi.com>:
> I have an object with String variable body. In the body is a newline
> character then some text. When this is being posted the newline seems to
> be being trimmed is there any way to stop this please?

Posted? Where?
And what are you using? Struts 1 or Struts 2?

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org