You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Struts Newsgroup (@Basebeans.com)" <st...@basebeans.com> on 2002/06/25 16:10:02 UTC
question
Subject: <bean:define> question
From: "David Chu" <da...@aol.net>
===
I am confused by the documentation concerning <bean:define>. Specifically,
I must write:
<bean:define id="crs" name="crs" value="My heebyjeeby string" scope="page"
/>
<bean:write name="crs" scope="page" />
In order to print out "My heebyjeeby string." I don't understand the
purpose of the "id" property and the "name" property. Why are both needed
and what purpose does one serve that the other does not?
-david
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: question
Posted by Nicolas De Loof <ni...@cgey.com>.
only "id" is required.
"id" set the name of the scripting variable AND context objet that tag will
define for you.
"toScope" set the scope to define the context object (PAGE by default)
If you specify "name" and/or "property", bean:define will look for this
object/property in "scope" (or in all scopes if not specified) for the value
of the object to be define.
If you specify a "value", tag will use it for the value of the object to be
define.
=> so name/property and value should not be used together !
"type" sets the java type of the scripting variable to be set
(java.lang.Object if omitted)
So, you can use :
<bean:define id="crs" value="My heebyjeeby string" type="java.lang.String"/>
<!-- a "crs" object is defined in page scope + a String script variable -->
<bean:write name="crs"/>
<!-- or the scriptlet way : -->
<%= crs %>
Nico
> Subject: <bean:define> question
> From: "David Chu" <da...@aol.net>
> ===
> I am confused by the documentation concerning <bean:define>.
Specifically,
> I must write:
>
> <bean:define id="crs" name="crs" value="My heebyjeeby string" scope="page"
> />
> <bean:write name="crs" scope="page" />
>
> In order to print out "My heebyjeeby string." I don't understand the
> purpose of the "id" property and the "name" property. Why are both
needed
> and what purpose does one serve that the other does not?
>
> -david
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: question
Posted by Jerome Jacobsen <je...@gentootech.com>.
The id attribute is used to identify a new bean when it is created. The
name attribute is used to refer to an existing bean. In your example remove
the name and scope attributes from bean:define.
<bean:define id="crs" value="My heebyjeeby string" scope="page/>
You are creating a new bean with the value attribute so the name and scope
attributes are not needed. If you were trying to create the crs bean in a
specified scope you would use the toScope attribute.
To create a new bean with a value from an existing bean use the name
attribute and optionally the property attribute and not the value attribute.
Example:
<bean:define id="crs" value="My heebyjeeby string" toScope="page"/>
<%-- Create a bean with the same value as the crs bean, except put it in
session scope. --%>
<bean:define id="crsalias" name="crs" scope="page" toScope="session"/>
<%-- Now crsalias is set to "My heebyjeeby string". --%>
-----Original Message-----
From: Struts Newsgroup [mailto:@Basebeans.comstruts@basebeans.com]
Sent: Tuesday, June 25, 2002 10:10 AM
To: struts-user@jakarta.apache.org
Subject: <bean:define> question
Subject: <bean:define> question
From: "David Chu" <da...@aol.net>
===
I am confused by the documentation concerning <bean:define>. Specifically,
I must write:
<bean:define id="crs" name="crs" value="My heebyjeeby string" scope="page"
/>
<bean:write name="crs" scope="page" />
In order to print out "My heebyjeeby string." I don't understand the
purpose of the "id" property and the "name" property. Why are both needed
and what purpose does one serve that the other does not?
-david
--
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>