You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Roland Berger <ro...@plenum-systems.ch> on 2001/11/08 17:23:33 UTC
AW: How to assign a form property to a String variable in jsp page
Yes, the id varString will be your scripting variable if you use
<bean:define id="varString" name="myClass" property="myString"/>
You can type <%= varString %> and you should see the value.
Roland
-----Ursprüngliche Nachricht-----
Von: Yunming.Li@fisonline.com [mailto:Yunming.Li@fisonline.com]
Gesendet: Donnerstag, 8. November 2001 17:00
An: struts-user@jakarta.apache.org
Betreff: RE: How to assign a form property to a String variable in jsp
page
but I need it to be a variable so I can do some calculations on them or some
'if else' operations, such as,
<%if varString.equals("goodString"){%>
<tr><td>good string</td></tr>
<%}else{ %>
<tr><td>bad string</td></tr>
<%}%>
-----Original Message-----
From: Siggelkow, Bill [mailto:bill.siggelkow@mirant.com]
Sent: Thursday, November 08, 2001 10:44 AM
To: 'Struts Users Mailing List'
Subject: RE: How to assign a form property to a String variable in jsp
pag e
Use the <bean:define> tag as follows ... (much better than scriptlet)
<bean:define id="varString" name="myClass" property="myString"/>
-----Original Message-----
From: Yunming.Li@fisonline.com [mailto:Yunming.Li@fisonline.com]
Sent: Thursday, November 08, 2001 10:29 AM
To: struts-user@jakarta.apache.org
Subject: RE: How to assign a form property to a String variable in jsp
pag e
I have the same problem with getting form property and assign to a var in
jsp page, say, a String.
If I put this in my jsp page,
<bean:write name="myClass" property="myString" filter="true" />
it will print "The String".
But now I want to put this string, "The String" to a String variable.
<% String varSting = ??? %>
Could anyone replace the ??? so the varString's value will be "The String"?
If I use
<% String varSting =<bean:write name="myClass" property="myString"
filter="true" /> %>
It will get compiling error.
Thanks
-----Original Message-----
From: David Winterfeldt [mailto:dwinterfeldt@yahoo.com]
Sent: Wednesday, November 07, 2001 11:36 AM
To: Struts Users Mailing List
Subject: Re: Passing Attributes of a FormBean to a JavaScript handler
You just use bean:write to embed the value in your
javascript if size isn't a field on the form?
private int size = <bean:write name="myForm"
property="size" />;
David
--- Tolstoy.Patel@us.cgeyc.com wrote:
>
>
>
> Hi all -
>
> How do I pass an attribute of a FormBean to a a
> JavaScript function? I am
> sending the Javascript function, FormBean code and
> struts tag that invokes
> the javascript function. The problem is in the
> struts tag onclick
> attribute. When I hard code the number 3, it works.
> But how do I retrieve
> the attribute from the form bean and pass it to the
> Javascript function?
>
> Also, I know that the bean is in scope!!!
>
> Your help is much appreciated. Thanks.
>
> -Tolstoy-
>
> +Javascript function -
> dosomething(size)
> {
> alert("The size is " + size);
> }
>
> +FormBean -
> public class SizeForm extends
> org.apache.struts.action.ActionForm{
> private int size;
> public getSize(){return size;}
> public setSize(int newSize){size = newSize;}
> }
>
> +Struts tag (This is where the problem is !!!!!)
> <html:button property="sizedisplay" value = "Show
> Size" onclick
> = "dosomething(SizeForm.size)" />
>
> +struts-config.xml
> clearly specified that form bean's logical name is
> "SizeForm" and the type
> is com.xxxx.xxx.SizeForm. I know this is correct.
>
>
>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
__________________________________________________
Do You Yahoo!?
Find a job, post your resume.
http://careers.yahoo.com
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>