struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leo mj <leomj2...@yahoo.com>
Subject RE: Forward to the same page
Date Fri, 08 Sep 2006 09:03:10 GMT
hi antonio,


 It can be done by using ActionForwards.Also go tru internatinalization in struts
for displaying langauage :
http://www.allapplabs.com/struts/struts_internationalization.htm


in the action class use
  ActionForward forward=new ActionForward();

if(chk whther the language  combo box has been selected ){

  forward=mapping.getInputForward();

}

add internationalization code using 
<bean:messageKey>
get language to be selected using request.getAttribute("fieldName");

in ur jsp...

Regards,
Leo







  

Artem Zhmurov <dark031@yandex.ru> wrote: What about using JavaScript? Try this:




 
Changing location 



 
function changeLanguage(lang){
 var location = window.location.href;
 if(location.indexOf("?") == -1){
  location += "?lang=";
  location += lang;
  window.location = location;
 } else {
  var pos = location.indexOf("lang=");
  if(pos != -1){
   var new_location = location.substring(0, pos + 5);
   new_location += lang;
   window.location = new_location;
  } else {
   location += "&lang=";
   location += lang;
   window.location = location;
  }
 }
}



 [input]  
 [input]  



It will work if you don't need the addition page (such as when dealing with
login).

Also you have to be sure, that your lang=.. parameter is in the end of
parameters line (that is true until you're not trying to add lang=..
somewhere outside). And there will be problem if your application dealing
with parameters named, for example, 'XXXlang'. All imperfections mentioned
can be removed by some little changes in script.

> -----Original Message-----
> From: Antonio Petrelli [mailto:brenmcguire@tariffenet.it]
> Sent: Friday, August 25, 2006 12:09 PM
> To: Struts Users Mailing List
> Subject: Re: Forward to the same page
> 
> Thomas Hamacher ha scritto:
> > How do I forward to the same page I was coming from? The typical example
> for
> > this is the "change-language-problem". Someone is on one page and simply
> > wants to change the language and expects to see the same page in a
> different
> > language.
> >
> 
> Just an idea,  tag has the "action" attribute that is no more
> required. If it is not specified the last servlet path (i.e. "post
> back") will be taken.
> http://struts.apache.org/1.x/struts-taglib/tlddoc/html/form.html
> You could grab the code that controls the value of the "action"
> attribute to determine the path you're coming from. Then you "change the
> language" and then redirect (I think it's better than forwarding) to the
> previous servlet path.
> 
> HTH
> Antonio
> 
> 
> ---------------------------------------------------------------------
> 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



 		
---------------------------------
How low will we go? Check out Yahoo! Messenger’s low  PC-to-Phone call rates.
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message