You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Arpan <ar...@gmail.com> on 2010/03/19 09:43:53 UTC

Struts 1 log out issue

Hi,

I our project we need to put a dynamic log out link,which will come from a
properties file.
While logging out we want to invalidate the session also.

I have written a logout action class where i m invalidating and removing the
attribute from the session.
Then after success in struts-config.xml file I am redirecting to the log out
url,which is hard coded.

Does any one know how to access properties file constants into
struts-config.xml.
And should be the best way to do.

Thanks

Re: Struts 1 log out issue

Posted by Arpan <ar...@gmail.com>.
Anyone can tell me..how to get property files attributes in
struts-config.xml file.
I want to use dynamic "path",which I will get from properties file for
logging out.

Thanks

On Fri, Mar 19, 2010 at 8:45 PM, Arpan <ar...@gmail.com> wrote:

> Thanks for the response.
>
> Is there any way struts-cofig.xml read any properties file?
>
>
> On Fri, Mar 19, 2010 at 8:06 PM, Girish Naik <gi...@gmail.com>wrote:
>
>> There are multiple ways to do it.
>>
>> one is to write a piece of code where we can use redirect dispatcher for
>> redirecting to the required url.
>> second on click of logout link take the user to a jsp where session is
>> invalidated , after this forward the user to the desired location.
>>
>>
>> Regards,
>> ---------------------------------------------------------
>> Girish Naik
>> Mobile:-+91-09740091638
>> girish.naik@gmail.com
>>
>>
>> On Fri, Mar 19, 2010 at 7:05 PM, Arpan <ar...@gmail.com> wrote:
>>
>> > No it doesn't work
>> >
>> > On Fri, Mar 19, 2010 at 6:19 PM, Brian Thompson <elephantium@gmail.com
>> > >wrote:
>> >
>> > > I'm not 100% sure, but ${property-name} might work.
>> > >
>> > > -Brian
>> > >
>> > >
>> > > On Fri, Mar 19, 2010 at 3:43 AM, Arpan <ar...@gmail.com>
>> wrote:
>> > > > Hi,
>> > > >
>> > > > I our project we need to put a dynamic log out link,which will come
>> > from
>> > > a
>> > > > properties file.
>> > > > While logging out we want to invalidate the session also.
>> > > >
>> > > > I have written a logout action class where i m invalidating and
>> > removing
>> > > the
>> > > > attribute from the session.
>> > > > Then after success in struts-config.xml file I am redirecting to the
>> > log
>> > > out
>> > > > url,which is hard coded.
>> > > >
>> > > > Does any one know how to access properties file constants into
>> > > > struts-config.xml.
>> > > > And should be the best way to do.
>> > > >
>> > > > Thanks
>> > > >
>> > >
>> > > ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> > > For additional commands, e-mail: user-help@struts.apache.org
>> > >
>> > >
>> >
>>
>
>
>

Re: Struts 1 log out issue

Posted by Arpan <ar...@gmail.com>.
Thanks for the response.

Is there any way struts-cofig.xml read any properties file?

On Fri, Mar 19, 2010 at 8:06 PM, Girish Naik <gi...@gmail.com> wrote:

> There are multiple ways to do it.
>
> one is to write a piece of code where we can use redirect dispatcher for
> redirecting to the required url.
> second on click of logout link take the user to a jsp where session is
> invalidated , after this forward the user to the desired location.
>
>
> Regards,
> ---------------------------------------------------------
> Girish Naik
> Mobile:-+91-09740091638
> girish.naik@gmail.com
>
>
> On Fri, Mar 19, 2010 at 7:05 PM, Arpan <ar...@gmail.com> wrote:
>
> > No it doesn't work
> >
> > On Fri, Mar 19, 2010 at 6:19 PM, Brian Thompson <elephantium@gmail.com
> > >wrote:
> >
> > > I'm not 100% sure, but ${property-name} might work.
> > >
> > > -Brian
> > >
> > >
> > > On Fri, Mar 19, 2010 at 3:43 AM, Arpan <ar...@gmail.com> wrote:
> > > > Hi,
> > > >
> > > > I our project we need to put a dynamic log out link,which will come
> > from
> > > a
> > > > properties file.
> > > > While logging out we want to invalidate the session also.
> > > >
> > > > I have written a logout action class where i m invalidating and
> > removing
> > > the
> > > > attribute from the session.
> > > > Then after success in struts-config.xml file I am redirecting to the
> > log
> > > out
> > > > url,which is hard coded.
> > > >
> > > > Does any one know how to access properties file constants into
> > > > struts-config.xml.
> > > > And should be the best way to do.
> > > >
> > > > Thanks
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
>

Re: Struts 1 log out issue

Posted by Girish Naik <gi...@gmail.com>.
There are multiple ways to do it.

one is to write a piece of code where we can use redirect dispatcher for
redirecting to the required url.
second on click of logout link take the user to a jsp where session is
invalidated , after this forward the user to the desired location.


Regards,
---------------------------------------------------------
Girish Naik
Mobile:-+91-09740091638
girish.naik@gmail.com


On Fri, Mar 19, 2010 at 7:05 PM, Arpan <ar...@gmail.com> wrote:

> No it doesn't work
>
> On Fri, Mar 19, 2010 at 6:19 PM, Brian Thompson <elephantium@gmail.com
> >wrote:
>
> > I'm not 100% sure, but ${property-name} might work.
> >
> > -Brian
> >
> >
> > On Fri, Mar 19, 2010 at 3:43 AM, Arpan <ar...@gmail.com> wrote:
> > > Hi,
> > >
> > > I our project we need to put a dynamic log out link,which will come
> from
> > a
> > > properties file.
> > > While logging out we want to invalidate the session also.
> > >
> > > I have written a logout action class where i m invalidating and
> removing
> > the
> > > attribute from the session.
> > > Then after success in struts-config.xml file I am redirecting to the
> log
> > out
> > > url,which is hard coded.
> > >
> > > Does any one know how to access properties file constants into
> > > struts-config.xml.
> > > And should be the best way to do.
> > >
> > > Thanks
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>

Re: Struts 1 log out issue

Posted by Arpan <ar...@gmail.com>.
No it doesn't work

On Fri, Mar 19, 2010 at 6:19 PM, Brian Thompson <el...@gmail.com>wrote:

> I'm not 100% sure, but ${property-name} might work.
>
> -Brian
>
>
> On Fri, Mar 19, 2010 at 3:43 AM, Arpan <ar...@gmail.com> wrote:
> > Hi,
> >
> > I our project we need to put a dynamic log out link,which will come from
> a
> > properties file.
> > While logging out we want to invalidate the session also.
> >
> > I have written a logout action class where i m invalidating and removing
> the
> > attribute from the session.
> > Then after success in struts-config.xml file I am redirecting to the log
> out
> > url,which is hard coded.
> >
> > Does any one know how to access properties file constants into
> > struts-config.xml.
> > And should be the best way to do.
> >
> > Thanks
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Struts 1 log out issue

Posted by Brian Thompson <el...@gmail.com>.
I'm not 100% sure, but ${property-name} might work.

-Brian


On Fri, Mar 19, 2010 at 3:43 AM, Arpan <ar...@gmail.com> wrote:
> Hi,
>
> I our project we need to put a dynamic log out link,which will come from a
> properties file.
> While logging out we want to invalidate the session also.
>
> I have written a logout action class where i m invalidating and removing the
> attribute from the session.
> Then after success in struts-config.xml file I am redirecting to the log out
> url,which is hard coded.
>
> Does any one know how to access properties file constants into
> struts-config.xml.
> And should be the best way to do.
>
> Thanks
>

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


Re: [Struts 2.1.8.1] Internationalization: how to remain in the current page ?

Posted by Paweł Wielgus <po...@gmail.com>.
Hi,
i don't remeber that for sure, but try s:url without action and
namespace, i think it might be what You are looking for.

Best greetings,
Pawel Wielgus.

2010/3/19, Ulf Liedén <ul...@gmail.com>:
> Hi Celinio,
>
> personally, I would build a method that gives back the URL of the page you
> are currently visiting, including all parameters. You put this method in a
> superclass of all your actions, so that its available everywhere. In the
> code you decide which locale parameter to set, according to your current
> locale.
>
> The method in the action class could look something like this:
>
>  public String getLocaleSwitchURL() { String url = getContextPath() +
> ServletActionContext.getActionMapping().getName() + ".action?" +
> "request_locale="; if (getLocale().toString().equals("en_EN")) { url +=
> "fr_FR"; flagURL = "fra.jpg"; } else { url += "en_EN"; flagURL = "eng.jpg";
> } url += "&"; url += ServletActionContext.getRequest().getQueryString();
> return url; } public String getFlagURL() { return getContextPath() +
> "images/" + this.flagURL; }
> All Strings should of course be configurable, and not hard coded like this.
> But just to give you an idea how it could work.  You output the link like
> this:
>
> <a href="<s:property value="localeSwitchURL" escape="false"/>">
>    <img src="<s:property value="flagURL" escape="false"/>" />
> </a>
>
> So if the user clicks the link, he will actually call the same page again,
> with the same parameters.
>
> Regards,
> Ulf
>
> On Fri, Mar 19, 2010 at 12:33 PM, Celinio Fernandes <ce...@yahoo.com>wrote:
>
>> hi,
>> I have a quick and basic question.
>> Regarding internationalization, whenever a user clicks on a link with a
>> flag, i want to change the locale (language)
>> of the web application.
>> That works well with the i18n interceptor.
>> However i always redirect the user to the home page (home.jsp) when i do
>> that because that is how i have setup the input result :
>>    <action name="changeLanguage" class="ServicesAction"
>>      method="changeLocale">
>>   <result name="input">/home/home.jsp</result>
>>    </action>
>>
>> My JSP looks like this :
>> <s:url id="url" action="changeLanguage.action">
>>      <s:param name="request_locale">fr</s:param>
>>     </s:url>
>>     <s:a href="%{url}" theme="xhtml"><img
>> src="<%=request.getContextPath()%>/images/flag_fr.png" /></s:a>
>>
>> So my question is :
>> how do you specify the current page in the input result name ?
>> so that the user stays on the current page when he changes languages.
>> Thanks for helping.
>>
>>
>>
>

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


Re: [Struts 2.1.8.1] Internationalization: how to remain in the current page ?

Posted by Ulf Liedén <ul...@gmail.com>.
Hi Celinio,

personally, I would build a method that gives back the URL of the page you
are currently visiting, including all parameters. You put this method in a
superclass of all your actions, so that its available everywhere. In the
code you decide which locale parameter to set, according to your current
locale.

The method in the action class could look something like this:

 public String getLocaleSwitchURL() { String url = getContextPath() +
ServletActionContext.getActionMapping().getName() + ".action?" +
"request_locale="; if (getLocale().toString().equals("en_EN")) { url +=
"fr_FR"; flagURL = "fra.jpg"; } else { url += "en_EN"; flagURL = "eng.jpg";
} url += "&"; url += ServletActionContext.getRequest().getQueryString();
return url; } public String getFlagURL() { return getContextPath() +
"images/" + this.flagURL; }
All Strings should of course be configurable, and not hard coded like this.
But just to give you an idea how it could work.  You output the link like
this:

<a href="<s:property value="localeSwitchURL" escape="false"/>">
   <img src="<s:property value="flagURL" escape="false"/>" />
</a>

So if the user clicks the link, he will actually call the same page again,
with the same parameters.

Regards,
Ulf

On Fri, Mar 19, 2010 at 12:33 PM, Celinio Fernandes <ce...@yahoo.com>wrote:

> hi,
> I have a quick and basic question.
> Regarding internationalization, whenever a user clicks on a link with a
> flag, i want to change the locale (language)
> of the web application.
> That works well with the i18n interceptor.
> However i always redirect the user to the home page (home.jsp) when i do
> that because that is how i have setup the input result :
>    <action name="changeLanguage" class="ServicesAction"
>      method="changeLocale">
>   <result name="input">/home/home.jsp</result>
>    </action>
>
> My JSP looks like this :
> <s:url id="url" action="changeLanguage.action">
>      <s:param name="request_locale">fr</s:param>
>     </s:url>
>     <s:a href="%{url}" theme="xhtml"><img
> src="<%=request.getContextPath()%>/images/flag_fr.png" /></s:a>
>
> So my question is :
> how do you specify the current page in the input result name ?
> so that the user stays on the current page when he changes languages.
> Thanks for helping.
>
>
>

Re: [Struts 2.1.8.1] Internationalization: how to remain in the current page ?

Posted by Alex Rodriguez Lopez <al...@flordeutopia.pt>.
Great remarks Denis, thanks!
Didn't know about includeParams="get"... already changed things to use 
that, works great! Simple and elegant solution, I too think urls like 
url/delete?id=# should be best avoided.

Using your approach (that is, closer to http specs, no deletes using GET 
method), how do you do it in the case of wanting to show the user a list 
of entities and direct links for deleting each one? I have my urls 
exposed because I use simple url to a deleting action with an ID as a 
GET param, how do you "generate" a link (or several in the same page) to 
a deleting action through POST? Do you always have to use forms?

Sorry if this has gone a little bit too off-topic.

Em 29-03-2010 13:14, Denis Cabasson escreveu:
> Hi,
>
> We use a simple and empty <s:url includeParam="get"/> tag to loop back
> to the current action/url.
>
> The only thing you have to look for are those "unsafe" urls: we don't
> have any "unsafe" urls in our application, thanks to an extensive POST
> then GET approach. Whenever some action is done in the application
> (through a POST), we process this action, update the relevant stuff in
> the database, and issue a redirect answer to a GET url, that will
> display the result of the action. That way, we can reload the current
> page (be it for switching language or just a browser reload) without any
> issue. This approach takes care of the bookmarking issue as well. I
> think this approach way more robust that tinkering with URLs to define
> safe and "unsafe" URLs.
>
> We had to do a bit a workaround code so that on the redirect to a GET,
> we don't lose all of our context. We actually save the current action in
> the session, and when the get comes back, pop it out of the session to
> place it in the stack. If somebody is interested, I can share that code....
>
> Denis.
>
> Le 2010-03-29 04:55, Alex Rodriguez Lopez a écrit :
>> Thanks Zoran for sharing your approach, greatly appreciated, I'm
>> thinking about implementing a similar interceptor, and maybe replace
>> the i18n one so work is done implicitly with only a change in
>> struts.xml and the new interceptor.
>>
>> Em 29-03-2010 02:58, Zoran Avtarovski escreveu:
>>> Hi Guys,
>>>
>>> We simplified it for struts to use a simple interceptor. Can’t show the
>>> exact code due to legal crap, but here’s the overview.
>>>
>>> In our base action we have a String called requestString, with
>>> appropriate getters and setters. We also have a Map<String, String> of
>>> unsafe URL’s and their safe counterparts. For example if the unsafe url
>>> was deleteObject.action it’s safe option would be listObject.action
>>>
>>> The interceptor uses the following code:
>>>
>>> if(unsafeUrls.get(request.getRequestURI()) != null)
>>> responseUrl = unsafeUrls.get(request.getRequestURI());
>>> else
>>> responseUrl = request.getRequestURI();
>>>
>>>
>>> StringBuffer rStr = new StringBuffer(responseUrl);
>>> rStr.append(“?”);
>>> for (Iterator iter = request.getParameterMap().keySet().iterator();
>>> iter.hasNext();) {
>>>
>>> String key = (String) iter.next();
>>> if (!"request_locale".equalsIgnoreCase(key)) {
>>> if (request.getParameter(key) != null) { // you can also include
>>> your own parameter specific exceptions. With the tag we used to have
>>> a comma delimited list of excluded parameters.
>>> rStr.append(key);
>>> rStr.append("=");
>>> rStr.append((String) request.getParameter(key));
>>> rStr.append("&");
>>> }
>>>
>>> }
>>> }
>>>
>>> action.setRequestString(sStr.toString());
>>>
>>>
>>>
>>> And then on the page we have:
>>>
>>> <div class=”localeFlag”><a
>>> href="${requestString}&request_locale=${localeOpt.lang}" ><img
>>> src="${pageContext.request.contextPath}/image/icons/${localeOpt.lang}_flag.gif"
>>>
>>> alt="<s:text name="%{“select.”+ attr.localeOpt.lang}" />"
>>> title="<s:text name="%{“select.”+ attr.localeOpt.lang}" />" /></a></div>
>>>
>>>
>>> I had to modify the code to satisfy our people but let me know if you
>>> have any questions. We use a complex parameter filtering process to
>>> unsure that security isn’t compromised.
>>>
>>> We’ve had to do quite a bit of i18n which has involved implementing DB
>>> based properties and tighter integration with S2 and spring.
>>>
>>> Z.
>>>
>>>
>>>
>>>
>>>
>>> Hi Zoran,
>>>
>>> would you mind sharing the code of this tag? It would be helpful to me,
>>> as somehow I've been able to link to the same sction with an empty url
>>> tag but unable to retain params. Thanks!
>>>
>>> Em 24-03-2010 22:42, Zoran Avtarovski escreveu:
>>> > I wrote a small custom tag which builds the link with the existing
>>> action
>>> > and parameters. This way it just reloads the page. I also included a
>>> > parameter that wouldn’t allow the change (a jQuery dialog would
>>> give the
>>> > user feed back) to take place if there might me an issue with system
>>> > integrity – for example submitting a form twice.
>>> >
>>> > Z.
>>> > >
>>> > > hi,
>>> > > I have a quick and basic question.
>>> > > Regarding internationalization, whenever a user clicks on a link
>>> with a flag,
>>> > > i want to change the locale (language)
>>> > > of the web application.
>>> > > That works well with the i18n interceptor.
>>> > > However i always redirect the user to the home page (home.jsp)
>>> when i do that
>>> > > because that is how i have setup the input result :
>>> > > <action name="changeLanguage" class="ServicesAction"
>>> > > method="changeLocale">
>>> > > <result name="input">/home/home.jsp</result>
>>> > > </action>
>>> > >
>>> > > My JSP looks like this :
>>> > > <s:url id="url" action="changeLanguage.action">
>>> > > <s:param name="request_locale">fr</s:param>
>>> > > </s:url>
>>> > > <s:a href="%{url}" theme="xhtml"><img
>>> > > src="<%=request.getContextPath()%>/images/flag_fr.png" /></s:a>
>>> > >
>>> > > So my question is :
>>> > > how do you specify the current page in the input result name ?
>>> > > so that the user stays on the current page when he changes
>>> languages.
>>> > > Thanks for helping.
>>> > >
>>> > >
>>> >
>>> >
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


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


Re: [Struts 2.1.8.1] Internationalization: how to remain in the current page ?

Posted by Denis Cabasson <de...@gmail.com>.
Hi,

We use a simple and empty <s:url includeParam="get"/> tag to loop back 
to the current action/url.

The only thing you have to look for are those "unsafe" urls: we don't 
have any "unsafe" urls in our application, thanks to an extensive POST 
then GET approach. Whenever some action is done in the application 
(through a POST), we process this action, update the relevant stuff in 
the database, and issue a redirect answer to a GET url, that will 
display the result of the action. That way, we can reload the current 
page (be it for switching language or just a browser reload) without any 
issue. This approach takes care of the bookmarking issue as well. I 
think this approach way more robust that tinkering with URLs to define 
safe and "unsafe" URLs.

We had to do a bit a workaround code so that on the redirect to a GET, 
we don't lose all of our context. We actually save the current action in 
the session, and when the get comes back, pop it out of the session to 
place it in the stack. If somebody is interested, I can share that code....

Denis.

Le 2010-03-29 04:55, Alex Rodriguez Lopez a écrit :
> Thanks Zoran for sharing your approach, greatly appreciated, I'm 
> thinking about implementing a similar interceptor, and maybe replace 
> the i18n one so work is done implicitly with only a change in 
> struts.xml and the new interceptor.
>
> Em 29-03-2010 02:58, Zoran Avtarovski escreveu:
>> Hi Guys,
>>
>> We simplified it for struts to use a simple interceptor. Can’t show the
>> exact code due to legal crap, but here’s the overview.
>>
>> In our base action we have a String called requestString, with
>> appropriate getters and setters. We also have a Map<String, String> of
>> unsafe URL’s and their safe counterparts. For example if the unsafe url
>> was deleteObject.action it’s safe option would be listObject.action
>>
>> The interceptor uses the following code:
>>
>> if(unsafeUrls.get(request.getRequestURI()) != null)
>> responseUrl = unsafeUrls.get(request.getRequestURI());
>> else
>> responseUrl = request.getRequestURI();
>>
>>
>> StringBuffer rStr = new StringBuffer(responseUrl);
>> rStr.append(“?”);
>> for (Iterator iter = request.getParameterMap().keySet().iterator();
>> iter.hasNext();) {
>>
>>     String key = (String) iter.next();
>>     if (!"request_locale".equalsIgnoreCase(key)) {
>>     if (request.getParameter(key) != null) { // you can also include
>>     your own parameter specific exceptions. With the tag we used to have
>>     a comma delimited list of excluded parameters.
>>     rStr.append(key);
>>     rStr.append("=");
>>     rStr.append((String) request.getParameter(key));
>>     rStr.append("&");
>>     }
>>
>> }
>> }
>>
>> action.setRequestString(sStr.toString());
>>
>>
>>
>> And then on the page we have:
>>
>> <div class=”localeFlag”><a
>> href="${requestString}&request_locale=${localeOpt.lang}" ><img
>> src="${pageContext.request.contextPath}/image/icons/${localeOpt.lang}_flag.gif" 
>>
>> alt="<s:text name="%{“select.”+ attr.localeOpt.lang}" />"
>> title="<s:text name="%{“select.”+ attr.localeOpt.lang}" />" /></a></div>
>>
>>
>> I had to modify the code to satisfy our people but let me know if you
>> have any questions. We use a complex parameter filtering process to
>> unsure that security isn’t compromised.
>>
>> We’ve had to do quite a bit of i18n which has involved implementing DB
>> based properties and tighter integration with S2 and spring.
>>
>> Z.
>>
>>
>>
>>
>>
>>     Hi Zoran,
>>
>>     would you mind sharing the code of this tag? It would be helpful 
>> to me,
>>     as somehow I've been able to link to the same sction with an 
>> empty url
>>     tag but unable to retain params. Thanks!
>>
>>     Em 24-03-2010 22:42, Zoran Avtarovski escreveu:
>> >  I wrote a small custom tag which builds the link with the existing
>>     action
>> >  and parameters. This way it just reloads the page. I also included a
>> >  parameter that wouldn’t allow the change (a jQuery dialog would
>>     give the
>> >  user feed back) to take place if there might me an issue with system
>> >  integrity – for example submitting a form twice.
>> >
>> >  Z.
>> > >
>> > > hi,
>> > > I have a quick and basic question.
>> > > Regarding internationalization, whenever a user clicks on a link
>>     with a flag,
>> > > i want to change the locale (language)
>> > > of the web application.
>> > > That works well with the i18n interceptor.
>> > > However i always redirect the user to the home page (home.jsp)
>>     when i do that
>> > > because that is how i have setup the input result :
>> > > <action name="changeLanguage" class="ServicesAction"
>> > > method="changeLocale">
>> > > <result name="input">/home/home.jsp</result>
>> > > </action>
>> > >
>> > > My JSP looks like this :
>> > > <s:url id="url" action="changeLanguage.action">
>> > > <s:param name="request_locale">fr</s:param>
>> > > </s:url>
>> > > <s:a href="%{url}" theme="xhtml"><img
>> > > src="<%=request.getContextPath()%>/images/flag_fr.png" /></s:a>
>> > >
>> > > So my question is :
>> > > how do you specify the current page in the input result name ?
>> > > so that the user stays on the current page when he changes 
>> languages.
>> > > Thanks for helping.
>> > >
>> > >
>> >
>> >
>>
>>
>>     
>> ---------------------------------------------------------------------
>>     To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>     For additional commands, e-mail: user-help@struts.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


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


RE: Pagination with Struts 2.1.8 ?

Posted by adam pinder <ap...@hotmail.co.uk>.
 
i prefer pagination to be db based so there is a minimum amount of data retrieved and held in memory. i.e. only retrieve what you will display. don't retrieve 200 records in memory and page through them.
 
adam


----------------------------------------
> Date: Mon, 29 Mar 2010 03:07:25 -0700
> From: cel975@yahoo.com
> Subject: Pagination with Struts 2.1.8 ?
> To: user@struts.apache.org
>
> Hi,
> This is a classic requirement.
> I have this table, in a JSP, that I have created with the 
html tag and that i have filled using the .
> This tag iterates over an ArrayList defined in my action.
> There are too many lines and I need to add some pagination functionality to it.
> What solutions are out there and which one do you recommend ?
> Thanks for your feedback.
>
>
> 		 	   		  
_________________________________________________________________
Do you have a story that started on Hotmail? Tell us now
http://clk.atdmt.com/UKM/go/195013117/direct/01/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Pagination with Struts 2.1.8 ?

Posted by Alex Rodriguez Lopez <al...@flordeutopia.pt>.
Em 29-03-2010 15:09, Celinio Fernandes escreveu:
> Thanks. I already read about it but does it work well with Struts 2 ?
>

Yes, I'm using it with S2. Include it in JSPs like this
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>

then, for example for a listing of users:

<display:table pagesize="10" sort="list" defaultsort="1"

                          uid="user"

                         name="users"

                   requestURI="user_list.action">



           <display:column sortable="true"

                           titleKey="label.name" property="name"

                           href="user_input.action" paramId="id"

                           paramProperty="userID"/>

	<%-- other columns of users --%>

</display:table>

This assumes you have a list of beans called "users" in your action, 
with a propertry named "name", with getters/setters.

Of course, if performance is a problem pagination would be best done at 
DB level as Adam suggested.

>
> --- On Mon, 3/29/10, Alex Rodriguez Lopez<al...@flordeutopia.pt>  wrote:
>
>
> From: Alex Rodriguez Lopez<al...@flordeutopia.pt>
> Subject: Re: Pagination with Struts 2.1.8 ?
> To: user@struts.apache.org
> Date: Monday, March 29, 2010, 4:32 AM
>
>
> Display tag, works like a charm:
>
> http://displaytag.sourceforge.net/1.2/tut_basic.html
>
> Works with lists and handles pagination, data export, I recommend it!
>
> Em 29-03-2010 11:07, Celinio Fernandes escreveu:
>> Hi,
>> This is a classic requirement.
>> I have this table, in a JSP, that I have created with the<table>   html tag and that i have filled using the<s:iterator>.
>> This<s:iterator>   tag iterates over an ArrayList defined in my action.
>> There are too many lines and I need to add some pagination functionality to it.
>> What solutions are out there and which one do you recommend ?
>> Thanks for your feedback.
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
>


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


Re: Pagination with Struts 2.1.8 ?

Posted by Zoran Avtarovski <zo...@sparecreative.com>.
We use display tag extensively and it ties into S2 really well.

We¹ve set it up to use DB based pagination so you only load the items you
need and it ties into S2 i18n properties.

We also use jqGrid which is based on jQuery and works really well where you
want ajax based tables.

Z.
> 
> Thanks. I already read about it but does it work well with Struts 2 ?
> 
> 
> --- On Mon, 3/29/10, Alex Rodriguez Lopez <al...@flordeutopia.pt> wrote:
> 
> 
> From: Alex Rodriguez Lopez <al...@flordeutopia.pt>
> Subject: Re: Pagination with Struts 2.1.8 ?
> To: user@struts.apache.org
> Date: Monday, March 29, 2010, 4:32 AM
> 
> 
> Display tag, works like a charm:
> 
> http://displaytag.sourceforge.net/1.2/tut_basic.html
> 
> Works with lists and handles pagination, data export, I recommend it!
> 
> Em 29-03-2010 11:07, Celinio Fernandes escreveu:
>> > Hi,
>> > This is a classic requirement.
>> > I have this table, in a JSP, that I have created with the<table>  html tag
>> and that i have filled using the<s:iterator>.
>> > This<s:iterator>  tag iterates over an ArrayList defined in my action.
>> > There are too many lines and I need to add some pagination functionality to
>> it.
>> > What solutions are out there and which one do you recommend ?
>> > Thanks for your feedback.
>> >
>> >
>> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> 


Re: Pagination with Struts 2.1.8 ?

Posted by Celinio Fernandes <ce...@yahoo.com>.
Thanks. I already read about it but does it work well with Struts 2 ?


--- On Mon, 3/29/10, Alex Rodriguez Lopez <al...@flordeutopia.pt> wrote:


From: Alex Rodriguez Lopez <al...@flordeutopia.pt>
Subject: Re: Pagination with Struts 2.1.8 ?
To: user@struts.apache.org
Date: Monday, March 29, 2010, 4:32 AM


Display tag, works like a charm:

http://displaytag.sourceforge.net/1.2/tut_basic.html

Works with lists and handles pagination, data export, I recommend it!

Em 29-03-2010 11:07, Celinio Fernandes escreveu:
> Hi,
> This is a classic requirement.
> I have this table, in a JSP, that I have created with the<table>  html tag and that i have filled using the<s:iterator>.
> This<s:iterator>  tag iterates over an ArrayList defined in my action.
> There are too many lines and I need to add some pagination functionality to it.
> What solutions are out there and which one do you recommend ?
> Thanks for your feedback.
>
>
>


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




      

Re: Pagination with Struts 2.1.8 ?

Posted by Alex Rodriguez Lopez <al...@flordeutopia.pt>.
Display tag, works like a charm:

http://displaytag.sourceforge.net/1.2/tut_basic.html

Works with lists and handles pagination, data export, I recommend it!

Em 29-03-2010 11:07, Celinio Fernandes escreveu:
> Hi,
> This is a classic requirement.
> I have this table, in a JSP, that I have created with the<table>  html tag and that i have filled using the<s:iterator>.
> This<s:iterator>  tag iterates over an ArrayList defined in my action.
> There are too many lines and I need to add some pagination functionality to it.
> What solutions are out there and which one do you recommend ?
> Thanks for your feedback.
>
>
>


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


Pagination with Struts 2.1.8 ?

Posted by Celinio Fernandes <ce...@yahoo.com>.
Hi, 
This is a classic requirement.
I have this table, in a JSP, that I have created with the <table> html tag and that i have filled using the <s:iterator>.
This <s:iterator> tag iterates over an ArrayList defined in my action.
There are too many lines and I need to add some pagination functionality to it.
What solutions are out there and which one do you recommend ? 
Thanks for your feedback.


      

Re: [Struts 2.1.8.1] Internationalization: how to remain in the current page ?

Posted by Alex Rodriguez Lopez <al...@flordeutopia.pt>.
Thanks Zoran for sharing your approach, greatly appreciated, I'm 
thinking about implementing a similar interceptor, and maybe replace the 
i18n one so work is done implicitly with only a change in struts.xml and 
the new interceptor.

Em 29-03-2010 02:58, Zoran Avtarovski escreveu:
> Hi Guys,
>
> We simplified it for struts to use a simple interceptor. Can’t show the
> exact code due to legal crap, but here’s the overview.
>
> In our base action we have a String called requestString, with
> appropriate getters and setters. We also have a Map<String, String> of
> unsafe URL’s and their safe counterparts. For example if the unsafe url
> was deleteObject.action it’s safe option would be listObject.action
>
> The interceptor uses the following code:
>
> if(unsafeUrls.get(request.getRequestURI()) != null)
> responseUrl = unsafeUrls.get(request.getRequestURI());
> else
> responseUrl = request.getRequestURI();
>
>
> StringBuffer rStr = new StringBuffer(responseUrl);
> rStr.append(“?”);
> for (Iterator iter = request.getParameterMap().keySet().iterator();
> iter.hasNext();) {
>
>     String key = (String) iter.next();
>     if (!"request_locale".equalsIgnoreCase(key)) {
>     if (request.getParameter(key) != null) { // you can also include
>     your own parameter specific exceptions. With the tag we used to have
>     a comma delimited list of excluded parameters.
>     rStr.append(key);
>     rStr.append("=");
>     rStr.append((String) request.getParameter(key));
>     rStr.append("&");
>     }
>
> }
> }
>
> action.setRequestString(sStr.toString());
>
>
>
> And then on the page we have:
>
> <div class=”localeFlag”><a
> href="${requestString}&request_locale=${localeOpt.lang}" ><img
> src="${pageContext.request.contextPath}/image/icons/${localeOpt.lang}_flag.gif"
> alt="<s:text name="%{“select.”+ attr.localeOpt.lang}" />"
> title="<s:text name="%{“select.”+ attr.localeOpt.lang}" />" /></a></div>
>
>
> I had to modify the code to satisfy our people but let me know if you
> have any questions. We use a complex parameter filtering process to
> unsure that security isn’t compromised.
>
> We’ve had to do quite a bit of i18n which has involved implementing DB
> based properties and tighter integration with S2 and spring.
>
> Z.
>
>
>
>
>
>     Hi Zoran,
>
>     would you mind sharing the code of this tag? It would be helpful to me,
>     as somehow I've been able to link to the same sction with an empty url
>     tag but unable to retain params. Thanks!
>
>     Em 24-03-2010 22:42, Zoran Avtarovski escreveu:
>     >  I wrote a small custom tag which builds the link with the existing
>     action
>     >  and parameters. This way it just reloads the page. I also included a
>     >  parameter that wouldn’t allow the change (a jQuery dialog would
>     give the
>     >  user feed back) to take place if there might me an issue with system
>     >  integrity – for example submitting a form twice.
>     >
>     >  Z.
>     > >
>     > > hi,
>     > > I have a quick and basic question.
>     > > Regarding internationalization, whenever a user clicks on a link
>     with a flag,
>     > > i want to change the locale (language)
>     > > of the web application.
>     > > That works well with the i18n interceptor.
>     > > However i always redirect the user to the home page (home.jsp)
>     when i do that
>     > > because that is how i have setup the input result :
>     > > <action name="changeLanguage" class="ServicesAction"
>     > > method="changeLocale">
>     > > <result name="input">/home/home.jsp</result>
>     > > </action>
>     > >
>     > > My JSP looks like this :
>     > > <s:url id="url" action="changeLanguage.action">
>     > > <s:param name="request_locale">fr</s:param>
>     > > </s:url>
>     > > <s:a href="%{url}" theme="xhtml"><img
>     > > src="<%=request.getContextPath()%>/images/flag_fr.png" /></s:a>
>     > >
>     > > So my question is :
>     > > how do you specify the current page in the input result name ?
>     > > so that the user stays on the current page when he changes languages.
>     > > Thanks for helping.
>     > >
>     > >
>     >
>     >
>
>
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>     For additional commands, e-mail: user-help@struts.apache.org
>


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


Re: [Struts 2.1.8.1] Internationalization: how to remain in the current page ?

Posted by Zoran Avtarovski <zo...@sparecreative.com>.
Hi Guys,

We simplified it for struts to use a simple interceptor.  Can¹t show the
exact code due to legal crap, but here¹s the overview.

In our base action we have a String called requestString, with appropriate
getters and setters. We also have a Map<String, String> of unsafe URL¹s and
their safe counterparts. For example if the unsafe url was
deleteObject.action it¹s safe option would be listObject.action

The interceptor uses the following code:

        if(unsafeUrls.get(request.getRequestURI()) != null)
                responseUrl = unsafeUrls.get(request.getRequestURI());
        else
                responseUrl = request.getRequestURI();


        StringBuffer rStr = new StringBuffer(responseUrl);
        rStr.append(³?²);
        for (Iterator iter = request.getParameterMap().keySet().iterator();
iter.hasNext();) {
>         String key = (String) iter.next();
>         if (!"request_locale".equalsIgnoreCase(key)) {
>             if (request.getParameter(key) != null) { // you can also include
> your own parameter specific exceptions. With the tag we used to have a comma
> delimited list of excluded parameters.
>                 rStr.append(key);
>                 rStr.append("=");
>                 rStr.append((String) request.getParameter(key));
>                 rStr.append("&");
>             }
             }
        }

        action.setRequestString(sStr.toString());



        And then on the page we have:

        <div class=²localeFlag²><a
href="${requestString}&request_locale=${localeOpt.lang}" ><img
src="${pageContext.request.contextPath}/image/icons/${localeOpt.lang}_flag.g
if" alt="<s:text name="%{³select.²+ attr.localeOpt.lang}" />"
                 title="<s:text name="%{³select.²+ attr.localeOpt.lang}" />"
/></a></div>


I had to modify the code to satisfy our people but let me know if you have
any questions. We use a complex parameter filtering process to unsure that
security isn¹t compromised.

We¹ve had to do quite a bit of i18n which has involved implementing DB based
properties and tighter integration with S2 and spring.

Z.
> 
> 
> 
> 
> Hi Zoran,
> 
> would you mind sharing the code of this tag? It would be helpful to me,
> as somehow I've been able to link to the same sction with an empty url
> tag but unable to retain params. Thanks!
> 
> Em 24-03-2010 22:42, Zoran Avtarovski escreveu:
>> > I wrote a small custom tag which builds the link with the existing action
>> > and parameters. This way it just reloads the page. I also included a
>> > parameter that wouldn¹t allow the change (a jQuery dialog would give the
>> > user feed back) to take place if there might me an issue with system
>> > integrity ­ for example submitting a form twice.
>> >
>> > Z.
>>> >>
>>> >> hi,
>>> >> I have a quick and basic question.
>>> >> Regarding internationalization, whenever a user clicks on a link with a
>>> flag,
>>> >> i want to change the locale (language)
>>> >> of the web application.
>>> >> That works well with the i18n interceptor.
>>> >> However i always redirect the user to the home page (home.jsp) when i do
>>> that
>>> >> because that is how i have setup the input result :
>>> >>     <action name="changeLanguage" class="ServicesAction"
>>> >>       method="changeLocale">
>>> >>    <result name="input">/home/home.jsp</result>
>>> >>     </action>
>>> >>
>>> >> My JSP looks like this :
>>> >> <s:url id="url" action="changeLanguage.action">
>>> >>       <s:param name="request_locale">fr</s:param>
>>> >>      </s:url>
>>> >>      <s:a href="%{url}" theme="xhtml"><img
>>> >> src="<%=request.getContextPath()%>/images/flag_fr.png" /></s:a>
>>> >>
>>> >> So my question is :
>>> >> how do you specify the current page in the input result name ?
>>> >> so that the user stays on the current page when he changes languages.
>>> >> Thanks for helping.
>>> >>
>>> >>
>> >
>> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


Re: [Struts 2.1.8.1] Internationalization: how to remain in the current page ?

Posted by Alex Rodriguez Lopez <al...@flordeutopia.pt>.
Hi Zoran,

would you mind sharing the code of this tag? It would be helpful to me, 
as somehow I've been able to link to the same sction with an empty url 
tag but unable to retain params. Thanks!

Em 24-03-2010 22:42, Zoran Avtarovski escreveu:
> I wrote a small custom tag which builds the link with the existing action
> and parameters. This way it just reloads the page. I also included a
> parameter that wouldn¹t allow the change (a jQuery dialog would give the
> user feed back) to take place if there might me an issue with system
> integrity ­ for example submitting a form twice.
>
> Z.
>>
>> hi,
>> I have a quick and basic question.
>> Regarding internationalization, whenever a user clicks on a link with a flag,
>> i want to change the locale (language)
>> of the web application.
>> That works well with the i18n interceptor.
>> However i always redirect the user to the home page (home.jsp) when i do that
>> because that is how i have setup the input result :
>>     <action name="changeLanguage" class="ServicesAction"
>>       method="changeLocale">
>>    <result name="input">/home/home.jsp</result>
>>     </action>
>>
>> My JSP looks like this :
>> <s:url id="url" action="changeLanguage.action">
>>       <s:param name="request_locale">fr</s:param>
>>      </s:url>
>>      <s:a href="%{url}" theme="xhtml"><img
>> src="<%=request.getContextPath()%>/images/flag_fr.png" /></s:a>
>>
>> So my question is :
>> how do you specify the current page in the input result name ?
>> so that the user stays on the current page when he changes languages.
>> Thanks for helping.
>>
>>
>
>


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


Re: [Struts 2.1.8.1] Internationalization: how to remain in the current page ?

Posted by Celinio Fernandes <ce...@yahoo.com>.
Thanks.
 
Could you share that code ? It would be useful and much appreciated.
Thanks again.
 

--- On Wed, 3/24/10, Zoran Avtarovski <zo...@sparecreative.com> wrote:


From: Zoran Avtarovski <zo...@sparecreative.com>
Subject: Re: [Struts 2.1.8.1] Internationalization: how to remain in the current page ?
To: "Struts Users Mailing List" <us...@struts.apache.org>, "Celinio Fernandes" <ce...@yahoo.com>
Date: Wednesday, March 24, 2010, 3:42 PM


I wrote a small custom tag which builds the link with the existing action
and parameters. This way it just reloads the page. I also included a
parameter that wouldn¹t allow the change (a jQuery dialog would give the
user feed back) to take place if there might me an issue with system
integrity ­ for example submitting a form twice.

Z.
> 
> hi,
> I have a quick and basic question.
> Regarding internationalization, whenever a user clicks on a link with a flag,
> i want to change the locale (language)
> of the web application.
> That works well with the i18n interceptor.
> However i always redirect the user to the home page (home.jsp) when i do that
> because that is how i have setup the input result :
>    <action name="changeLanguage" class="ServicesAction"
>      method="changeLocale">
>   <result name="input">/home/home.jsp</result>
>    </action>
>    
> My JSP looks like this :
> <s:url id="url" action="changeLanguage.action">
>      <s:param name="request_locale">fr</s:param>
>     </s:url>
>     <s:a href="%{url}" theme="xhtml"><img
> src="<%=request.getContextPath()%>/images/flag_fr.png" /></s:a>  
>    
> So my question is :
> how do you specify the current page in the input result name ?
> so that the user stays on the current page when he changes languages.
> Thanks for helping.
> 
> 




      

Re: [Struts 2.1.8.1] Internationalization: how to remain in the current page ?

Posted by Zoran Avtarovski <zo...@sparecreative.com>.
I wrote a small custom tag which builds the link with the existing action
and parameters. This way it just reloads the page. I also included a
parameter that wouldn¹t allow the change (a jQuery dialog would give the
user feed back) to take place if there might me an issue with system
integrity ­ for example submitting a form twice.

Z.
> 
> hi,
> I have a quick and basic question.
> Regarding internationalization, whenever a user clicks on a link with a flag,
> i want to change the locale (language)
> of the web application.
> That works well with the i18n interceptor.
> However i always redirect the user to the home page (home.jsp) when i do that
> because that is how i have setup the input result :
>    <action name="changeLanguage" class="ServicesAction"
>      method="changeLocale">
>   <result name="input">/home/home.jsp</result>
>    </action>
>    
> My JSP looks like this :
> <s:url id="url" action="changeLanguage.action">
>      <s:param name="request_locale">fr</s:param>
>     </s:url>
>     <s:a href="%{url}" theme="xhtml"><img
> src="<%=request.getContextPath()%>/images/flag_fr.png" /></s:a>  
>    
> So my question is :
> how do you specify the current page in the input result name ?
> so that the user stays on the current page when he changes languages.
> Thanks for helping.
> 
> 


[Struts 2.1.8.1] Internationalization: how to remain in the current page ?

Posted by Celinio Fernandes <ce...@yahoo.com>.
hi,
I have a quick and basic question.
Regarding internationalization, whenever a user clicks on a link with a flag, i want to change the locale (language)
of the web application.
That works well with the i18n interceptor.
However i always redirect the user to the home page (home.jsp) when i do that because that is how i have setup the input result :
   <action name="changeLanguage" class="ServicesAction" 
     method="changeLocale">
  <result name="input">/home/home.jsp</result>
   </action>
   
My JSP looks like this :
<s:url id="url" action="changeLanguage.action">
     <s:param name="request_locale">fr</s:param>
    </s:url>
    <s:a href="%{url}" theme="xhtml"><img src="<%=request.getContextPath()%>/images/flag_fr.png" /></s:a>   
   
So my question is :
how do you specify the current page in the input result name ?
so that the user stays on the current page when he changes languages.
Thanks for helping.