You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Otto, Frank" <ot...@delta-barth.de> on 2004/01/14 15:30:32 UTC

bean:write

Hello,
 
I want to write a string like "line1<br>line2".
 
If I use <bean:write name="myForm" property="myProperty"/>, I will get line1&lt;br&gtline2.
If I use <bean:write name="myForm" property="myProperty" filter="false"/>, I will get line1<br>line2.
 
But I want to write:
 
line1
line2
 
How can I do this with struts?
 
 
Regards,
 
Frank

Error Page Flow

Posted by "Matthew J. Vincent" <vi...@cs.usm.maine.edu>.
Hello all,

I have a url that gets invoked with the url
http://localhost/prototype/search.do .  I have a SearchAction class that
uses EJBs to pull data from a database to populate a pick list in my search
JSP page.  I use some simple JSTL code to populate the select box:

<c:forEach var="strainType" items="${strainTypes}" varStatus="status">
       <option><c:out value="${strainType}" escapeXml="false"/></option>
</c:forEach>

I use the following Struts tag to create the <form> tag

<html:form action="SearchResults"
           name="search"
           type="SearchForm">

I have a SearchForm class that is a simple ActionForm.  When I submit the
form, I invoke my SearchResultsAction class, however this is where I need
help.  When an error occurs, how do I get back to my search.do page with my
select box (1) populated and (2) have the chosen option from the select box
selected?  Should I be using the Struts tag for a select box?  How do i
re-retrieve the values in the select box?  Am I making sense?

In my stuts-config.xml file I have:

      <action path = "/SearchResults"
              type = "SearchResultsAction"
              name = "SearchForm"
              scope = "request"
              validate = "true"
              input = "/search.jsp">
         <forward name="success" path="/search.do"/>
         <forward name="failure" path="/search.jsp"/>
         <forward name="error" path="/appError.jsp"/>
      </action>

Currently on an error, I am brought back to my search form with the errors
displayed, but the select box is not populated.

Help!

Thanks!

Matt





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


Re: bean:write

Posted by Mark Lowe <ma...@talk21.com>.
sorry kris, i think i misunderstood the original question, but i get 
what you saying with the delim character needing to be a character not 
a string. I think our man wants

filter="false" anyhow ..

On 14 Jan 2004, at 14:57, Kris Schneider wrote:

> The "delims" attribute of <c:forTokens> works just like the "delim" 
> argument to
> a StringTokenizer constructor. For example, if you do:
>
> StringTokenizer st = new StringTokenizer("line1<br>line2", "<br>", 
> true);
>
> Then st.countTokens() will return 6, not 3. In other words, the 
> "delims"
> attribute should be thought of as a set of delimiter characters, not 
> as a single
> delimiter string.
>
> Quoting Mark Lowe <ma...@talk21.com>:
>
>> So you want to replace <br> for \n or similar.
>>
>> <c:set var="str" value="${myForm.myProperty}" />
>> <c:forTokens var="tok" items="${str}" delims="<br>">
>> 	<c:out value="${tok}\n" />
>> ...
>>
>> This might work.
>>
>>
>> On 14 Jan 2004, at 14:30, Otto, Frank wrote:
>>
>>> Hello,
>>>
>>> I want to write a string like "line1<br>line2".
>>>
>>> If I use <bean:write name="myForm" property="myProperty"/>, I will 
>>> get
>>> line1&lt;br&gtline2.
>>> If I use <bean:write name="myForm" property="myProperty"
>>> filter="false"/>, I will get line1<br>line2.
>>>
>>> But I want to write:
>>>
>>> line1
>>> line2
>>>
>>> How can I do this with struts?
>>>
>>>
>>> Regards,
>>>
>>> Frank
>
> -- 
> Kris Schneider <ma...@dotech.com>
> D.O.Tech       <http://www.dotech.com/>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


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


Re: bean:write

Posted by Kris Schneider <kr...@dotech.com>.
The "delims" attribute of <c:forTokens> works just like the "delim" argument to
a StringTokenizer constructor. For example, if you do:

StringTokenizer st = new StringTokenizer("line1<br>line2", "<br>", true);

Then st.countTokens() will return 6, not 3. In other words, the "delims"
attribute should be thought of as a set of delimiter characters, not as a single
delimiter string.

Quoting Mark Lowe <ma...@talk21.com>:

> So you want to replace <br> for \n or similar.
> 
> <c:set var="str" value="${myForm.myProperty}" />
> <c:forTokens var="tok" items="${str}" delims="<br>">
> 	<c:out value="${tok}\n" />
> ...
> 
> This might work.
> 
> 
> On 14 Jan 2004, at 14:30, Otto, Frank wrote:
> 
> > Hello,
> >
> > I want to write a string like "line1<br>line2".
> >
> > If I use <bean:write name="myForm" property="myProperty"/>, I will get 
> > line1&lt;br&gtline2.
> > If I use <bean:write name="myForm" property="myProperty" 
> > filter="false"/>, I will get line1<br>line2.
> >
> > But I want to write:
> >
> > line1
> > line2
> >
> > How can I do this with struts?
> >
> >
> > Regards,
> >
> > Frank

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

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


Re: bean:write

Posted by Mark Lowe <ma...@talk21.com>.
So you want to replace <br> for \n or similar.

<c:set var="str" value="${myForm.myProperty}" />
<c:forTokens var="tok" items="${str}" delims="<br>">
	<c:out value="${tok}\n" />
...

This might work.


On 14 Jan 2004, at 14:30, Otto, Frank wrote:

> Hello,
>
> I want to write a string like "line1<br>line2".
>
> If I use <bean:write name="myForm" property="myProperty"/>, I will get 
> line1&lt;br&gtline2.
> If I use <bean:write name="myForm" property="myProperty" 
> filter="false"/>, I will get line1<br>line2.
>
> But I want to write:
>
> line1
> line2
>
> How can I do this with struts?
>
>
> Regards,
>
> Frank


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


Re: bean:write

Posted by Mike Deegan <mp...@hotmail.com>.
does it work with <br/> instead of <br>
because I have things working exactly as you would have with ...
<bean:write name="myForm" property="myProperty" filter="false"/>

filter="false" does the trick for me - only difference is my line breaks are
<br/> instead of <br>

not sure if that changes things for you

----- Original Message ----- 
From: "Otto, Frank" <ot...@delta-barth.de>
To: "Struts-User (E-Mail)" <st...@jakarta.apache.org>
Sent: Wednesday, January 14, 2004 7:30 AM
Subject: bean:write


> Hello,
>
> I want to write a string like "line1<br>line2".
>
> If I use <bean:write name="myForm" property="myProperty"/>, I will get
line1&lt;br&gtline2.
> If I use <bean:write name="myForm" property="myProperty" filter="false"/>,
I will get line1<br>line2.
>
> But I want to write:
>
> line1
> line2
>
> How can I do this with struts?
>
>
> Regards,
>
> Frank
>

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