You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "lei.java@gmail.com" <le...@gmail.com> on 2007/12/18 22:23:23 UTC
Is there a way to store a bean property value in a variable in view (JSP)?
Hi all,
I need to build a path to an image file in a JSP based on the value passed
to the JSP's action, either using an English button from <context
path>/*en*/closeBtn.gif
or using a French button from <context path>/*fr*/closeBtn.gif. Suppose the
parameter is called lang so the URL is like* .../login.action?lang=<en or
fr>*
**
There are two approaches, each of which has a problem which I need to figure
out.
*1. If the path is built in JSP*
In this case, I need to store the lang value in a variable and use it to
build the path like this:
<s:url value="/" includeParams="none" id="contextPath"/>
<img src="${contextPath}*???*/closeBtn.gif"/>
where ??? is either en or fr. How can I do it? I know lang can be streamed
out like <s:property value="lang"/> but it doesn't work if ??? is substitued
with <s:property value="lang"/>. Is there a way to read lang to a variable?
*2. If the path is built in the action class*
In this case, I need to get context path and use it to build the path. The
path can be stored as a bean property so its value can be accessed in view
using <s:property .../> tag.
The problem is how to get the context path from an action class?
Are there other ways to solve the problem?
Thanks a lot for any comments and help.
RE: Is there a way to store a bean property value in a variable in view (JSP)?
Posted by "Sekhar, Raja" <ra...@lehman.com>.
Try this
In the form define a hidden field and set its value like
<s:hidden name="startdate" value="<s:property
value="%{securityBean.startdate}" />"
theme="simple" />
I could get the value of this field later by accessing using
document.getElementById( 'startdate' ) inside my javascripts.
Hope this helps, correct me if I am completely off.
-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com]
Sent: Wednesday, December 19, 2007 4:27 AM
To: Struts Users Mailing List
Subject: Re: Is there a way to store a bean property value in a variable
in view (JSP)?
take a look at this example
<%@taglib prefix="s" uri="/struts-tags" %> <div
style="background-color:yellow;"> <p> JSP Custom Template - parameter
'paramName' - <s:property value="%{paramName}" /> </p> </div> reference
any parameter using OGNL ..this will help..
http://struts.apache.org/2.x/docs/ognl.html
you can cast off # if you are referencing Action properties
to prevent <mis>interpretations by JSP EL use this directive
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<el-ignored>true</el-ignored>
</jsp-property-group>
</jsp-config>Does this help?
M--
----- Original Message -----
From: <le...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Tuesday, December 18, 2007 4:39 PM
Subject: Re: Is there a way to store a bean property value in a variable
in view (JSP)?
> Hi everyone,
>
> Is it legal to define a EL variable to hold ${lei}<s:property
value="lang"
> />?
>
> Thanks.
>
>
> On Dec 18, 2007 4:23 PM, lei.java@gmail.com <le...@gmail.com>
wrote:
>
> > Hi all,
> >
> > I need to build a path to an image file in a JSP based on the value
passed
> > to the JSP's action, either using an English button from <context
path>/*
> > en*/closeBtn.gif or using a French button from <context path>/
*fr*/closeBtn.gif.
> > Suppose the parameter is called lang so the URL is
like*.../login.action?lang=<en or fr>
> > *
> > **
> > There are two approaches, each of which has a problem which I need
> > to figure out.
> >
> > *1. If the path is built in JSP*
> > In this case, I need to store the lang value in a variable and use
> > it to build the path like this:
> >
> > <
> > s:url value="/" includeParams ="none" id="contextPath" />
> >
> > <
> > img src="${contextPath}*???*/closeBtn.gif" />
> >
> > where ??? is either en or fr. How can I do it? I know lang can be
streamed
> > out like <s:property value="lang"/> but it doesn't work if ??? is
> > substitued with < s:property value="lang"/>. Is there a way to read
> > lang to a variable?
> >
> > *2. If the path is built in the action class*
> >
> > In this case, I need to get context path and use it to build the
path.
The
> > path can be stored as a bean property so its value can be accessed
> > in
view
> > using <s:property .../> tag.
> >
> > The problem is how to get the context path from an action class?
> >
> > Are there other ways to solve the problem?
> >
> > Thanks a lot for any comments and help.
> >
> >
> >
>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Is there a way to store a bean property value in a variable in view (JSP)?
Posted by Martin Gainty <mg...@hotmail.com>.
take a look at this example
<%@taglib prefix="s" uri="/struts-tags" %>
<div style="background-color:yellow;">
<p>
JSP Custom Template -
parameter 'paramName' - <s:property value="%{paramName}" />
</p>
</div>
reference any parameter using OGNL ..this will help..
http://struts.apache.org/2.x/docs/ognl.html
you can cast off # if you are referencing Action properties
to prevent <mis>interpretations by JSP EL use this directive
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<el-ignored>true</el-ignored>
</jsp-property-group>
</jsp-config>Does this help?
M--
----- Original Message -----
From: <le...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Tuesday, December 18, 2007 4:39 PM
Subject: Re: Is there a way to store a bean property value in a variable in
view (JSP)?
> Hi everyone,
>
> Is it legal to define a EL variable to hold ${lei}<s:property value="lang"
> />?
>
> Thanks.
>
>
> On Dec 18, 2007 4:23 PM, lei.java@gmail.com <le...@gmail.com> wrote:
>
> > Hi all,
> >
> > I need to build a path to an image file in a JSP based on the value
passed
> > to the JSP's action, either using an English button from <context
path>/*
> > en*/closeBtn.gif or using a French button from <context path>/
*fr*/closeBtn.gif.
> > Suppose the parameter is called lang so the URL is
like*.../login.action?lang=<en or fr>
> > *
> > **
> > There are two approaches, each of which has a problem which I need to
> > figure out.
> >
> > *1. If the path is built in JSP*
> > In this case, I need to store the lang value in a variable and use it to
> > build the path like this:
> >
> > <
> > s:url value="/" includeParams ="none" id="contextPath" />
> >
> > <
> > img src="${contextPath}*???*/closeBtn.gif" />
> >
> > where ??? is either en or fr. How can I do it? I know lang can be
streamed
> > out like <s:property value="lang"/> but it doesn't work if ??? is
> > substitued with < s:property value="lang"/>. Is there a way to read lang
> > to a variable?
> >
> > *2. If the path is built in the action class*
> >
> > In this case, I need to get context path and use it to build the path.
The
> > path can be stored as a bean property so its value can be accessed in
view
> > using <s:property .../> tag.
> >
> > The problem is how to get the context path from an action class?
> >
> > Are there other ways to solve the problem?
> >
> > Thanks a lot for any comments and help.
> >
> >
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Is there a way to store a bean property value in a variable in view (JSP)?
Posted by "lei.java@gmail.com" <le...@gmail.com>.
Hi everyone,
Is it legal to define a EL variable to hold ${lei}<s:property value="lang"
/>?
Thanks.
On Dec 18, 2007 4:23 PM, lei.java@gmail.com <le...@gmail.com> wrote:
> Hi all,
>
> I need to build a path to an image file in a JSP based on the value passed
> to the JSP's action, either using an English button from <context path>/*
> en*/closeBtn.gif or using a French button from <context path>/ *fr*/closeBtn.gif.
> Suppose the parameter is called lang so the URL is like*.../login.action?lang=<en or fr>
> *
> **
> There are two approaches, each of which has a problem which I need to
> figure out.
>
> *1. If the path is built in JSP*
> In this case, I need to store the lang value in a variable and use it to
> build the path like this:
>
> <
> s:url value="/" includeParams ="none" id="contextPath" />
>
> <
> img src="${contextPath}*???*/closeBtn.gif" />
>
> where ??? is either en or fr. How can I do it? I know lang can be streamed
> out like <s:property value="lang"/> but it doesn't work if ??? is
> substitued with < s:property value="lang"/>. Is there a way to read lang
> to a variable?
>
> *2. If the path is built in the action class*
>
> In this case, I need to get context path and use it to build the path. The
> path can be stored as a bean property so its value can be accessed in view
> using <s:property .../> tag.
>
> The problem is how to get the context path from an action class?
>
> Are there other ways to solve the problem?
>
> Thanks a lot for any comments and help.
>
>
>