Re: JSON plugin ignoring includeProperties parameter
There is a getItems() in your action right? Does anything get generated at all? musachy -- "Hey you! Would you help me to carry the stone?" Pink Floyd - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: JSON plugin ignoring includeProperties parameter
Martin Gainty wrote: Here is the code private List includeProperties; includeProperties is a List of Regular Expression java.util.regex.Patterns javadoc at http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html try expressing the String as a regex Pattern e.g. [i][t][e][m][s]\p{.}\p{*}\p{\}\p{.}[n][a][m][e] "foo" is a valid regular expression. There's no reason to (and at least two reasons *not* to) make every single character part of a character set/class, and I can't think of a good reason to match a literal "." with anything other than "\.", although I could be wrong on that one. I'm pretty sure something else is amiss. Dave - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: JSON plugin ignoring includeProperties parameter
Here is the code private List includeProperties; includeProperties is a List of Regular Expression java.util.regex.Patterns javadoc at http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html try expressing the String as a regex Pattern e.g. [i][t][e][m][s]\p{.}\p{*}\p{\}\p{.}[n][a][m][e] ? Martin Gainty __ Jogi és Bizalmassági kinyilatkoztatás/Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Ez az üzenet bizalmas. Ha nem ön az akinek szánva volt, akkor kérjük, hogy jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának készítése nem megengedett. Ez az üzenet csak ismeret cserét szolgál és semmiféle jogi alkalmazhatósága sincs. Mivel az electronikus üzenetek könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet ezen üzenet tartalma miatt. Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > Date: Thu, 21 May 2009 15:38:09 -0600 > From: john.c.cartwri...@noaa.gov > Subject: JSON plugin ignoring includeProperties parameter > To: user@struts.apache.org > > Hello All, > > I'm trying to use jsonplugin 0.32 w/ struts 2.0.14 and it seems that the > includeProperties parameter is being ignored. My configuration looks like: > > > true > > items.*\.name > > > > Can someone please help me w/ what might be wrong? > > Thanks! > > --john > > > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > _ Hotmail® has a new way to see what's up with your friends. http://windowslive.com/Tutorial/Hotmail/WhatsNew?ocid=TXT_TAGLM_WL_HM_Tutorial_WhatsNew1_052009
Re: JSON plugin ignoring includeProperties parameter
john.c.cartwri...@noaa.gov wrote: items.*\.name Can someone please help me w/ what might be wrong? Maybe the whitespace? Does it behave any differently if you do: items.*\.name ? -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
JSON plugin ignoring includeProperties parameter
Hello All, I'm trying to use jsonplugin 0.32 w/ struts 2.0.14 and it seems that the includeProperties parameter is being ignored. My configuration looks like: true items.*\.name Can someone please help me w/ what might be wrong? Thanks! --john - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
session timeout ---execute action in struts2
i configured in web.xml com.listener.SessionUserListener 1 but the valueUnbound in SessionUserListener is not executed when session is timeout,who can tell me why? ___ 好玩贺卡等你发,邮箱贺卡全新上线! http://card.mail.cn.yahoo.com/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Nested Struts2 iterator tags
thanks!! On Thu, May 21, 2009 at 2:29 PM, Martin Gainty wrote: > > //Assuming we have this Action > //A Simple Action Class which demonstrates placing information in a Map > public class GetEntryAction extends ActionSupport > { >private ArrayList stats_list=new ArrayList(30); //a collection of stats >private class stats >{ > private ArrayList entries_list=new ArrayList(30); // a collection of > Entries > String StatusGroupName="StatusGroupName"; > String StatusGroupID="StatusGroupID"; >} >private class Entry >{ >String HOHName; >public String getHOH Name() >{ >return HOHName; >} >public void setHOH Name(String HOHName) >{ >this.HOHName=HOHName; >} >String Price; >public String getPrice() >{ >return Price; >} >public void setPrice(String price) >{ >Price=price; >} >String OriginalValue; >public String getOriginalValue() >{ >return OriginalValue; >} >public void setOriginalValue(String str) >{ >OriginalValue=str; >} >} >public String execute() throws Exception >{ > >Map session = > ActionContext.getContext().getSession(); > > //construct new Uber stats class >stats stats1=new stats(); >stats1.StatusGroupName=new > String("StatusGroupName1"); >stats1.StatusGroupID=new String("StatusGroupID"); > >//Name,Value,OriginalValue > //construct the 1st entry >Entry entry1=new Entry(); >entry1.setHOHName("ALL"); >entry1.setPrice("50.00"); >entry1.setOriginalValue("10.00"); > //put it into stats Map >stats1.entries_list.add(entry1); > > //construct the second entry >Entry entry2=new Entry(); >entry2.setHOHName("ALL"); >entry2.setPrice("50.00"); >entry2.setOriginalValue("10.00"); > //put it into entries Map >stats1.entries_list.add(entry2); > >//put the stats class into stats_list >stats_list.add(stats1); > > //construct new Uber stats class >stats stats2=new stats(); >stats2.StatusGroupName=new > String("StatusGroupName2"); >stats2.StatusGroupID=new String("StatusGroupID2"); > > //construct the 1st entry >Entry entry2a=new Entry(); >entry2a.setHOHName("ALL"); >entry2a.setPrice("50.00"); >entry2a.setOriginalValue("10.00"); > //put it into stats Map >stats2.entries_list.add(entry2a); > > //construct the second entry >Entry entry2b=new Entry(); >entry2b.setHOHName("ALL"); >entry2b.setPrice("50.00"); >entry2b.setOriginalValue("10.00"); > //put it into entries Map >stats2.entries_list.add(entry2b); > >session.put("stats_list",stats_list); > //All of the information you require is now in the map which is now in the > Session >return SUCCESS; >} > } > > > ">oddeven"> > > > > > value="#session.stats_list.entries_list('#statsStatus.index')" > status="userStatus"> > > > test="!#userStatus.index">, > > > > > HTH > Martin Gainty > __ > Jogi és Bizalmassági kinyilatkoztatás/Verzicht und > Vertraulichkeitanmerkung/Note de déni et de confidentialité > Ez az > üzenet bizalmas. Ha nem ön az akinek szánva volt, akkor kérjük, hogy > jelentse azt nekünk vissza. Semmiféle továbbítása vagy másolatának > készítése nem megengedett. Ez az üzenet csak ismeret cserét szolgál és > semmiféle jogi alkalmazhatósága sincs. Mivel az electronikus üzenetek > könnyen megváltoztathatóak, ezért minket semmi felelöség nem terhelhet > ezen üzenet tartalma miatt. > > Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene > Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte > Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht > dient lediglich dem Austausch von Informationen und entfaltet keine > rechtliche Bindungswirkung. Au
RE: Nested Struts2 iterator tags
//Assuming we have this Action //A Simple Action Class which demonstrates placing information in a Map public class GetEntryAction extends ActionSupport { private ArrayList stats_list=new ArrayList(30); //a collection of stats private class stats { private ArrayList entries_list=new ArrayList(30); // a collection of Entries String StatusGroupName="StatusGroupName"; String StatusGroupID="StatusGroupID"; } private class Entry { String HOHName; public String getHOH Name() { return HOHName; } public void setHOH Name(String HOHName) { this.HOHName=HOHName; } String Price; public String getPrice() { return Price; } public void setPrice(String price) { Price=price; } String OriginalValue; public String getOriginalValue() { return OriginalValue; } public void setOriginalValue(String str) { OriginalValue=str; } } public String execute() throws Exception { Map session = ActionContext.getContext().getSession(); //construct new Uber stats class stats stats1=new stats(); stats1.StatusGroupName=new String("StatusGroupName1"); stats1.StatusGroupID=new String("StatusGroupID"); //Name,Value,OriginalValue //construct the 1st entry Entry entry1=new Entry(); entry1.setHOHName("ALL"); entry1.setPrice("50.00"); entry1.setOriginalValue("10.00"); //put it into stats Map stats1.entries_list.add(entry1); //construct the second entry Entry entry2=new Entry(); entry2.setHOHName("ALL"); entry2.setPrice("50.00"); entry2.setOriginalValue("10.00"); //put it into entries Map stats1.entries_list.add(entry2); //put the stats class into stats_list stats_list.add(stats1); //construct new Uber stats class stats stats2=new stats(); stats2.StatusGroupName=new String("StatusGroupName2"); stats2.StatusGroupID=new String("StatusGroupID2"); //construct the 1st entry Entry entry2a=new Entry(); entry2a.setHOHName("ALL"); entry2a.setPrice("50.00"); entry2a.setOriginalValue("10.00"); //put it into stats Map stats2.entries_list.add(entry2a); //construct the second entry Entry entry2b=new Entry(); entry2b.setHOHName("ALL"); entry2b.setPrice("50.00"); entry2b.setOriginalValue("10.00"); //put it into entries Map stats2.entries_list.add(entry2b); session.put("stats_list",stats_list); //All of the information you require is now in the map which is now in the Session return SUCCESS; } } oddeven"> , Date: Thu, 21 May 2009 12:28:50 -0400 > Subject: Nested Struts2 iterator tags > From: bhaara...@gmail.com > To: user@struts.apache.org > > Hi > I have two nested struts iterator tags. > > The value for second iterator tag is property from the first iterator. > > Something like this > > > > HOH Name | HOH DOB value="DOB"/> | Project > > > Member Name > Member DOB > Failed Verification Description > > "/> >. > . > > > > I would like to know what is the current syntax to achieve something like > this? _ Hotmail® goes with you. http://windowslive.com/Tutorial/Hotmail/Mobile?ocid=TXT_TAGLM_WL_HM_Tutorial_Mobile1_052009
Re: Block accessing in some path with filter.
Read the section on the config file elements in struts.xml on the Struts2 docs site. Also read the Interceptors guide[1]. You have to specify the interceptor stack on the action. You can use the element to specify what stack to use by default. And what you've defined is not an interceptor stack - it's just an interceptor alone. What you want to do is specify something like this: class="com.mycompany.myproduct.AdminInterceptor"/> That adds the admin interceptor to the bottom of the basic interceptor stack. Look at the docs - you'll get a faster answer than coming to the mailing list with every question. They really are very good docs, as docs go. Andy. [1] http://struts.apache.org/2.x/docs/interceptors.html On 21 May 2009, at 16:00, Stefano Tranquillini wrote: thanks, but i definide in struts my interceptors in this way: class="interceptors.AdminLogin"/> in order to use the interceptors only when namespace is /admin/* but the interceptor is never called! And: where i've to put the globalforward? i putted a the end of the sturts.xml something like that has to be inside package or something else? the error is: 2009-05-21 16:56:51,171 ERROR [com.opensymphony.xwork2.util.DomHelper] (HDScanner) Element type "global-forwards" must be declared. at (null:92:22) org.xml.sax.SAXParseException: Element type "global-forwards" must be declared. 2009/5/21 Stefano : 2009/5/21 Paweł Wielgus : global forward thanks, but i definide in struts my interceptors in this way: class="interceptors.AdminLogin"/> in order to use the interceptors only when namespace is /admin/* but the interceptor is never called! ideas? thanks -- Stefano -- Stefano - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Nested Struts2 iterator tags
nevermind... this works: On Thu, May 21, 2009 at 12:28 PM, Bhaarat Sharma wrote: > Hi > I have two nested struts iterator tags. > > The value for second iterator tag is property from the first iterator. > > Something like this > > > > HOH Name | HOH DOB value="DOB"/> | Project > > > Member Name > Member DOB > Failed Verification Description > > "/> > >. > . > > > > I would like to know what is the current syntax to achieve something like > this? > >
Nested Struts2 iterator tags
Hi I have two nested struts iterator tags. The value for second iterator tag is property from the first iterator. Something like this HOH Name | HOH DOB| Project Member Name Member DOB Failed Verification Description "/> . . I would like to know what is the current syntax to achieve something like this?
Re: Block accessing in some path with filter.
Big problem folks. i already have an interceptor form the ejb. so i need to use both of these interceptors. i've to update the DEFAULT PACKAGE in this way: i can't simply add the interceptor in the package admin and set default-interceptor at my LoginInterceptor, because otherwise the ejb3 interceptor is not called! well, now the adminLogin is always called. but how can i check if the action is in the namespace /admin? or, i can put the interceptor in package /admin and adding this interceptor at new.stack? 2009/5/21 Stefano Tranquillini : > thanks, > > but i definide in struts my interceptors in this way: > > > > > > > in order to use the interceptors only when namespace is /admin/* > > but the interceptor is never called! > > And: > > > where i've to put the globalforward? > i putted a the end of the sturts.xml > > something like that > > > > > > has to be inside package or something else? > > the error is: > > 2009-05-21 16:56:51,171 ERROR [com.opensymphony.xwork2.util.DomHelper] > (HDScanner) Element type "global-forwards" must be declared. at > (null:92:22) > org.xml.sax.SAXParseException: Element type "global-forwards" must be > declared. > > > > 2009/5/21 Stefano : >> 2009/5/21 Paweł Wielgus : >>> global forward >> >> thanks, >> >> but i definide in struts my interceptors in this way: >> >> >> >> >> >> >> in order to use the interceptors only when namespace is /admin/* >> >> but the interceptor is never called! >> >> ideas? >> >> thanks >> >> -- >> Stefano >> > > > > -- > Stefano > -- Stefano - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Block accessing in some path with filter.
thanks, but i definide in struts my interceptors in this way: in order to use the interceptors only when namespace is /admin/* but the interceptor is never called! And: where i've to put the globalforward? i putted a the end of the sturts.xml something like that has to be inside package or something else? the error is: 2009-05-21 16:56:51,171 ERROR [com.opensymphony.xwork2.util.DomHelper] (HDScanner) Element type "global-forwards" must be declared. at (null:92:22) org.xml.sax.SAXParseException: Element type "global-forwards" must be declared. 2009/5/21 Stefano : > 2009/5/21 Paweł Wielgus : >> global forward > > thanks, > > but i definide in struts my interceptors in this way: > > > > > > > in order to use the interceptors only when namespace is /admin/* > > but the interceptor is never called! > > ideas? > > thanks > > -- > Stefano > -- Stefano - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Block accessing in some path with filter.
2009/5/21 Paweł Wielgus : > global forward thanks, but i definide in struts my interceptors in this way: in order to use the interceptors only when namespace is /admin/* but the interceptor is never called! ideas? thanks -- Stefano - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Preload of database data?
It's mostly a matter of preference, in some scenarios, using the action tag makes more sense. There is information here - http://cwiki.apache.org/WW/crud-demo-i.html#CRUDDemoI-Adding&Editinganemployee -Wes On Thu, May 21, 2009 at 10:37 AM, Luis Medina wrote: > Does anyone know which is the diference between "prepare data" using the > Action Constructor and the prepare method? > > On Thu, May 21, 2009 at 6:18 AM, wrote: > >> You can prepare data by implemeting Preparable in your action >> >> On Tue, May 19, 2009 at 4:48 PM, Christian Benjamin Ries < >> christian_benjamin.r...@fh-bielefeld.de> wrote: >> >> > Hi there, >> > >> > I have a small site with some informations which are stored in a >> > database. A method for administrations reason is added to change the >> > content (names) of the datasets. >> > >> > Now, I will add these names to my navigation. >> > >> > I have a action like this: >> > >> > >> > ... >> > >> > >> > This action edits the content of the bean "System". >> > >> > I will add this bean content to all other actions in my navigation, but >> > I don't know the right way to solve this problem. Any suggestions? >> > >> > Thx! >> > >> > - >> > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> > For additional commands, e-mail: user-h...@struts.apache.org >> > >> > >> > > > > -- > Luis Alberto Medina Bravo > Skype: lalbertme > Móvil: 553 715 5290 > MSN: luis.med...@acm.org > -- > Worker bees can leave > Even drones can fly away > The queen is their slave > -- Wes Wannemacher Author - Struts 2 In Practice Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more http://www.manning.com/wannemacher - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Block accessing in some path with filter.
Hi Stefano, use global forward. Best greetings, Paweł Wielgus. 2009/5/21 Stefano Tranquillini : > I've some problem with filter. > so i'll try with interceptor. > > i've done something like that: > > public String intercept(ActionInvocation invocation) throws Exception { > Map session = ActionContext.getContext().getSession(); > Object o = session.get("logged"); > boolean ret = false; > if (o != null) { > String admin = "" + o; > if (admin.equals("admin")) { > ret = true; > } > } > if (ret) { > return invocation.invoke(); > } else { > return "denied"; > } > } > > but when i mapped the interceptor, how can i choose what i've to do? > i've to put a result named denied in each action? > > On Wed, May 20, 2009 at 15:28, Andy Sykes wrote: >> You need to include elements in your filter mappings for the >> Struts filter. >> >> eg. >> >> >> struts2 >> /* >> REQUEST >> FORWARD >> >> >> With no element specified, the container assumes you mean the >> filter chain only gets applied to requests. >> >> The FORWARD element means the filter chain will get >> invoked when a servlet performs a forward (as your code does). >> >> Just FYI - you may want to consider doing your protection with Interceptors, >> since it's a bit less clumsy than lugging around servlet filters with >> Struts. >> >> You can very easily write an Interceptor[1] that will return a certain >> result type (say "denied") based on whether a specified attribute exists in >> the user's session. Doing so is left as an exercise to the reader :) >> >> You're not then limited to using mappings in the web.xml, and all the logic >> is embedded in the framework you've chosen. >> >> Struts' interceptors are a very powerful AOP-style pattern that I think are >> sometimes overlooked and aren't emphasised enough... >> >> [1] http://struts.apache.org/2.x/docs/writing-interceptors.html >> >> On 20 May 2009, at 13:42, Stefano Tranquillini wrote: >> >>> now is taked. but i've some problem with the dispacer. >>> i've an action mapped in this way: >>> >>> denied >>> >>> >>> namespace is / >>> >>> if i manually put in this url: >>> http://localhost:8080//WAP-Shop-war/denied.action its WORKS. >>> >>> the filter, else branch is this: >>> else { >>> RequestDispatcher rd = null; >>> rd = sc.getRequestDispatcher("/denied.action"); >>> rd.forward(myRequest, myResponse); >>> } >>> >>> and has to recall the same url see above, but he returns an error (404): >>> >>> type Status report >>> >>> message /WAP-Shop-war/denied.action >>> >>> description The requested resource (/WAP-Shop-war/denied.action) is >>> not available. >>> >>> but is available! >>> >>> ideas? >>> >>> >>> >>> On Wed, May 20, 2009 at 13:35, Andy Sykes wrote: Put the mapping for the admin filter above the struts2 filter. Filters are invoked in the order in web.xml, first to last. The struts filter is catching the request first and dispatching it before it ever reaches the admin filter. On 20 May 2009, at 09:37, Stefano Tranquillini wrote: > Hi all. > i need to block the path /admin/ for all the pepole. only the people > logged in as root can access it. > i've done a filter, but struts seems to dosen't works with its > > > struts2 > > > org.apache.struts2.dispatcher.FilterDispatcher > > > adminFilter > filter.AdminFilter > > > struts2 > /* > > > adminFilter > /admin/* > > > public class AdminFilter implements Filter { > > FilterConfig fc; > > public AdminFilter() { > } > > public void init(FilterConfig fc) throws ServletException { > this.fc = fc; > } > > public void doFilter(ServletRequest request, ServletResponse > response, FilterChain chain) throws IOException, ServletException { > > System.out.println("i'm the filter!"); > > > HttpServletResponse myResponse = (HttpServletResponse) response; > HttpServletRequest myRequest = (HttpServletRequest) request; > String user = (String) > myRequest.getSession().getAttribute("logged"); > ServletContext sc = fc.getServletContext(); > if (user.equals("admin")) { > > > String requestURI = myRequest.getRequestURI(); > int pathLength = myRequest.getContextPath().length(); > StringBuffer relativeURI = new > StringBuffer(requestURI.substring(pathLength)); > String query = myRequest.getQueryString(); > if (query != null) { > relativeURI.append("?").append(query); > } > RequestDispatcher rd = null; > if
Re: Preload of database data?
Does anyone know which is the diference between "prepare data" using the Action Constructor and the prepare method? On Thu, May 21, 2009 at 6:18 AM, wrote: > You can prepare data by implemeting Preparable in your action > > On Tue, May 19, 2009 at 4:48 PM, Christian Benjamin Ries < > christian_benjamin.r...@fh-bielefeld.de> wrote: > > > Hi there, > > > > I have a small site with some informations which are stored in a > > database. A method for administrations reason is added to change the > > content (names) of the datasets. > > > > Now, I will add these names to my navigation. > > > > I have a action like this: > > > > > > ... > > > > > > This action edits the content of the bean "System". > > > > I will add this bean content to all other actions in my navigation, but > > I don't know the right way to solve this problem. Any suggestions? > > > > Thx! > > > > - > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > > > > -- Luis Alberto Medina Bravo Skype: lalbertme Móvil: 553 715 5290 MSN: luis.med...@acm.org -- Worker bees can leave Even drones can fly away The queen is their slave
Re: Block accessing in some path with filter.
I've some problem with filter. so i'll try with interceptor. i've done something like that: public String intercept(ActionInvocation invocation) throws Exception { Map session = ActionContext.getContext().getSession(); Object o = session.get("logged"); boolean ret = false; if (o != null) { String admin = "" + o; if (admin.equals("admin")) { ret = true; } } if (ret) { return invocation.invoke(); } else { return "denied"; } } but when i mapped the interceptor, how can i choose what i've to do? i've to put a result named denied in each action? On Wed, May 20, 2009 at 15:28, Andy Sykes wrote: > You need to include elements in your filter mappings for the > Struts filter. > > eg. > > > struts2 > /* > REQUEST > FORWARD > > > With no element specified, the container assumes you mean the > filter chain only gets applied to requests. > > The FORWARD element means the filter chain will get > invoked when a servlet performs a forward (as your code does). > > Just FYI - you may want to consider doing your protection with Interceptors, > since it's a bit less clumsy than lugging around servlet filters with > Struts. > > You can very easily write an Interceptor[1] that will return a certain > result type (say "denied") based on whether a specified attribute exists in > the user's session. Doing so is left as an exercise to the reader :) > > You're not then limited to using mappings in the web.xml, and all the logic > is embedded in the framework you've chosen. > > Struts' interceptors are a very powerful AOP-style pattern that I think are > sometimes overlooked and aren't emphasised enough... > > [1] http://struts.apache.org/2.x/docs/writing-interceptors.html > > On 20 May 2009, at 13:42, Stefano Tranquillini wrote: > >> now is taked. but i've some problem with the dispacer. >> i've an action mapped in this way: >> >> denied >> >> >> namespace is / >> >> if i manually put in this url: >> http://localhost:8080//WAP-Shop-war/denied.action its WORKS. >> >> the filter, else branch is this: >> else { >> RequestDispatcher rd = null; >> rd = sc.getRequestDispatcher("/denied.action"); >> rd.forward(myRequest, myResponse); >> } >> >> and has to recall the same url see above, but he returns an error (404): >> >> type Status report >> >> message /WAP-Shop-war/denied.action >> >> description The requested resource (/WAP-Shop-war/denied.action) is >> not available. >> >> but is available! >> >> ideas? >> >> >> >> On Wed, May 20, 2009 at 13:35, Andy Sykes wrote: >>> >>> Put the mapping for the admin filter above the struts2 filter. Filters >>> are >>> invoked in the order in web.xml, first to last. >>> >>> The struts filter is catching the request first and dispatching it before >>> it >>> ever reaches the admin filter. >>> >>> On 20 May 2009, at 09:37, Stefano Tranquillini wrote: >>> Hi all. i need to block the path /admin/ for all the pepole. only the people logged in as root can access it. i've done a filter, but struts seems to dosen't works with its struts2 org.apache.struts2.dispatcher.FilterDispatcher adminFilter filter.AdminFilter struts2 /* adminFilter /admin/* public class AdminFilter implements Filter { FilterConfig fc; public AdminFilter() { } public void init(FilterConfig fc) throws ServletException { this.fc = fc; } public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { System.out.println("i'm the filter!"); HttpServletResponse myResponse = (HttpServletResponse) response; HttpServletRequest myRequest = (HttpServletRequest) request; String user = (String) myRequest.getSession().getAttribute("logged"); ServletContext sc = fc.getServletContext(); if (user.equals("admin")) { String requestURI = myRequest.getRequestURI(); int pathLength = myRequest.getContextPath().length(); StringBuffer relativeURI = new StringBuffer(requestURI.substring(pathLength)); String query = myRequest.getQueryString(); if (query != null) { relativeURI.append("?").append(query); } RequestDispatcher rd = null; if (relativeURI.toString().length() > 0) { rd = sc.getRequestDispatcher(relativeURI.toString()); } else { rd = sc.getRequestDispatcher("/WAP-Shop-war/"); } rd.forward(myRequest, myResponse);
RE: IllegalStateException: Cannot forward. Response already committed.
Hi, I tried out your suggestions and I am still getting this exception. I even put everything in the JSP in one line and mad sure there were no whitespaces. <%@ taglib uri="http://struts.apache.org/tags-logic"; prefix="logic"%><%@ page contentType="text/html" import="org.apache.log4j.Logger"%><%final Logger log = Logger.getLogger("index.jsp");log.debug("begin");%> Any other ideas? -Original Message- From: Wes Wannemacher [mailto:w...@wantii.com] Sent: Wednesday, May 20, 2009 4:48 PM To: Struts Users Mailing List Subject: Re: IllegalStateException: Cannot forward. Response already committed. The JSP compiler simple turns those <% %> tags inside out and everything outside of those tags is a string with an out.print... In your case, the first two things in the file generate returns... Whitespace is significant... Let me see if I can make it visually more understandable Index.jsp <%@ taglib uri="http://struts.apache.org/tags-logic"; prefix="logic"%> < RIGHT HERE, You will get a out.print("\n"); <%@ page contentType="text/html" import="org.apache.log4j.Logger"%> <- SAME HERE <% Hopefully it doesn't get all wrapped and screwed up. You might be wondering now, why does it work sometimes and not others... Well, the IllegalStateException is only thrown if output has been flushed, so you can get away with breaking the rules from time to time. You can even set the page buffer variable really high so that you reserve the right to redirect, even if you have generated some output. Anyhow, try to remove whitespace, you could probably just do it this way and have it work - Index.jsp -> <%@ taglib uri="http://struts.apache.org/tags-logic"; prefix="logic" %><%@ page contentType="text/html" import="org.apache.log4j.Logger" %><% final Logger log = Logger.getLogger("index.jsp"); log.debug("begin"); %> On Wed, May 20, 2009 at 4:39 PM, Hermann X Lau wrote: > Thanks in advance for any help on this... > > I understand we get this exception when the JSP attempts to write to the > print stream after the response has been committed but I don't see how this > is occurring in my situation since my JSP just contains a simple forward. > > Index.jsp > <%@ taglib uri="http://struts.apache.org/tags-logic"; prefix="logic"%> > <%@ page contentType="text/html" import="org.apache.log4j.Logger"%> > <% > final Logger log = Logger.getLogger("index.jsp"); > log.debug("begin"); > %> > > > Here is my action class (note that in my logs, this exception occurs even > before the execute method is called!): > public class ChoiceAction extends StrutsAction { > > public ActionForward execute(ActionMapping mapping, ActionForm > form, HttpServletRequest request, HttpServletResponse response) throws > Exception { > log4j.debug("execute"); > ManifestChoiceFormBean choiceForm = > (ManifestChoiceFormBean) form; > Connection conn = > DAOUtils.getConnection("jdbc/OSURptDb"); > > try { > RenderRequest req = > (RenderRequest)request.getAttribute("javax.portlet.request"); > String sites = > getResources(request).getMessage("upsws.site.list." + > req.getPreferences().getValue("SITE_IND","").toLowerCase()); > log4j.debug(sites); > IMailManifestDAO dao = > DAOBuilder.buildMailManifestDAO(conn); > boolean uspsActive = > dao.uspsJobsExist(sites); > > choiceForm.setUspsActive(uspsActive); > log4j.info("USPS link is " + > ((uspsActive) ? " active": " not active")); > > return > mapping.findForward("next"); > > } finally { > DAOUtils.closeConnection(conn); > } > } > static final Logger log4j = > Logger.getLogger(ChoiceAction.class); > } > > log: > INFO : 2009-05-20 16:26:18,581 > com.bbb.adf.controller.WpsStrutsPortletOSU:WpsStrutsPortletOSU init() using > URL = file:/usr/WebSphere/wps61/wp_profile/installedApps/ret7a15 > 9/PA_MailManifest.ear/MailManifest.war/WEB-INF/classes/log4j.properties > DEBUG: 2009-05-20 16:26:19,264 index.jsp:begin > ERROR: 2009-05-20 16:26:19,713 com.bbb.exceptions.DefaultHandler:Exception > caught by default handler. > javax.portlet.PortletException: javax.portlet.PortletException: > javax.servlet.jsp.JspException: Exception forwarding for name welcome: > java.lang.IllegalStateException: Cannot > forward. Response already committed. > at > com.ibm.portal.st
RE: Accessing protected resources via a login page
Hi Stuart, You're quite right. I'm not sure how I missed this as I actually logged the output from getQueryString! Still, this has certainly simplified my code. My interceptor calls setUrl on the action. This URL is then passed through a tag on the login form via a getUrl call. If the interceptor finds that the user is not logged in it aborts returning "login". This is handled as follows: - /goLoginPage.action?url=${encodedUrl} Here I specifically encode the URL. My base action has the following getter in addition to the normal getUrl and setUrl public String getEncodedUrl () throws java.io.UnsupportedEncodingException { return java.net.URLEncoder.encode (url, "UTF-8"); } Struts automatically decodes the parameters so no decoding method is required. Cheers, Steve -Original Message- From: Stuart Ellidge [mailto:stuart.elli...@adaptris.com] Sent: 20 May 2009 17:11 To: Struts Users Mailing List Subject: Re: Accessing protected resources via a login page Hi Steve, Glad to hear you got it working - just as an observation (and I really haven't tested this to check, so it is a question), but would HttpServletRequest.getQueryString() not have provided you with the original parameters? So a combination of both getRequestURL and getQueryString could have provided you with the complete request string. Anyway, the real reason for responding is that I'm not sure what you mean with when you mention the single parameter issue. At some stage soon I'll probably be adding query string (parameter) support into our interceptor and if you could post an example, I can file it away for future reference. Thanks Stuart On 20/05/2009 17:00, "Steve" wrote: Thanks to Stuart, Lukasz and Wes for your advice. I decided to stick with a home-grown solution because I'm only interested in GET's right now and I don't want the complexity of adding Spring into the mix with EJB3, Struts and JPA already working well together. This is because I haven't used Spring before. It's all working now but Spring may have been a better option! Stuart's code worked fine until I bought parameters into the mix. Unfortunately getRequestURL () doesn't return the parameters and I couldn't find any other method that did. Therefore I had to iterate through the parameters map and rebuild the parameters part of the request URL. This worked fine with a single parameter but failed with two or more parameters. This turned out to be a known issue with the redirect result when used with ${url}. In this case the returned string is not URL encoded so the single url parameter gets split on the embedded &. I added an extra method to the action (getEncodedURL ()) and then used ${encodedUrl}. This worked fine as the parameters interceptor automatically decodes parameters. Cheers, Steve -Original Message- From: Stuart Ellidge [mailto:stuart.elli...@adaptris.com] Sent: 19 May 2009 16:56 To: Struts Users Mailing List Subject: Re: Accessing protected resources via a login page Hi Steve, What you are asking is relatively simple really - we implemented an interceptor to capture the current request URL and store it in the current value stack. We can subsequently reference it in our JSPs and use it in forms in several places to enable us to redirect to the original page after certain events occur. Here is the intercept method: public String intercept(ActionInvocation invocation) throws Exception { HttpServletRequest request = ServletActionContext.getRequest(); StringBuffer returnUrl = new StringBuffer(request.getRequestURL()); invocation.getStack().set("returnURL", returnUrl);return invocation.invoke(); } In your example, you would add setUrl and getUrl methods to the login action class and then use the ${returnURL} in your JSP to create the request parameter / hidden input. Also, don't forget about the ability to use OGNL within your results... so your result could be of type "redirect" sending to a location of ${url} (that being the parameter name in your example below, and resolving to LoginAction.getUrl(). Regards Stuart p.s. the reason for using the interceptor, rather than just accessing the request URL directly in the JSP is that by the time the JSP is rendered, that URL points to the JSP itself, rather than the action. On 19/05/2009 16:44, "Steve" wrote: I would rather avoid using Acegi as I'm not using Spring. I'm using Struts 2 and EJB3. I appreciate the Acegi can be used without Spring. But it still seems like overkill to solve this one issue. I was hoping to generate a call to login.action like ".../login.action?url=". I guess storing the request string in the session would work just as well. Do you know the easiest way to access the request string from an interceptor or action? Many Thanks, Steve -Original Message- From: Lukasz Lenart [mailto:lukasz.len...@googlemail.com] Sent: 19 May 2009 15:26 To: Struts Users Mailing List Subjec
Re: How to get request locale in OGNL?
typo..I try to use #request.locale now .. On Thu, May 21, 2009 at 7:51 PM, Gordian Yuan wrote: > Thank you for your rapid response > > I try to use #context.locale now. It's look fine.But I'm not sure > > When i write , output is zh_CN > > But i write , output is > > {__sitemesh__filterapplied=true, > __spring_security_filterSecurityInterceptor_filterApplied=true, > __spring_security_session_fixation_filter_applied=true, > __spring_security_session_integration_filter_applied=true, > __cleanup_recursion_counter=1, struts.request_uri=/agencyx/signin.action, > javax.servlet.forward.servlet_path=/signin.action, > struts.view_uri=/jsp/signin.jsp, lazyLoadingFilter.FILTERED=true, > struts.valuestack=com.opensymphony.xwork2.ognl.ognlvaluest...@443799, > javax.servlet.forward.request_uri=/agencyx/signin.action, > javax.servlet.forward.context_path=/agencyx} > > I can't find where is locale property ... > > Gordian Yuan > > On Thu, May 21, 2009 at 7:27 PM, wrote: > >> invocation.getStack().findString(#attr.locale) >> >> On Thu, May 21, 2009 at 6:22 AM, Gordian Yuan >> wrote: >> >> > Hi, >> > >> > I want to know how to get request locale in OGNL? >> > >> > For now I use > > >> > >> value='#session.WW_TRANS_I18N_LOCALE?#session.WW_TRANS_I18N_LOCALE.toString():"zh_CN"'/> >> > >> > This must assume that the initial value is "zh_CN". >> > >> > So I need to know how to get request locale in OGNL. >> > >> > Thx >> > >> > Gordian Yuan >> > >> > >
Re: How to get request locale in OGNL?
Thank you for your rapid response I try to use #context.locale now. It's look fine.But I'm not sure When i write , output is zh_CN But i write , output is {__sitemesh__filterapplied=true, __spring_security_filterSecurityInterceptor_filterApplied=true, __spring_security_session_fixation_filter_applied=true, __spring_security_session_integration_filter_applied=true, __cleanup_recursion_counter=1, struts.request_uri=/agencyx/signin.action, javax.servlet.forward.servlet_path=/signin.action, struts.view_uri=/jsp/signin.jsp, lazyLoadingFilter.FILTERED=true, struts.valuestack=com.opensymphony.xwork2.ognl.ognlvaluest...@443799, javax.servlet.forward.request_uri=/agencyx/signin.action, javax.servlet.forward.context_path=/agencyx} I can't find where is locale property ... Gordian Yuan On Thu, May 21, 2009 at 7:27 PM, wrote: > invocation.getStack().findString(#attr.locale) > > On Thu, May 21, 2009 at 6:22 AM, Gordian Yuan > wrote: > > > Hi, > > > > I want to know how to get request locale in OGNL? > > > > For now I use > > > > value='#session.WW_TRANS_I18N_LOCALE?#session.WW_TRANS_I18N_LOCALE.toString():"zh_CN"'/> > > > > This must assume that the initial value is "zh_CN". > > > > So I need to know how to get request locale in OGNL. > > > > Thx > > > > Gordian Yuan > > >
Re: passing form parameters to a custom validator
Did it this way. Passed field names via the tag, then obtained values inside the validator class using getFieldValue(fieldName, object). Thank you for suggestions. stanlick wrote: > > Rather than pass this, that and the other parameter(s) to your validator, > why not just retrieve what you need from inside the validator? You have > the > ActionInvocation passed to your doIntercept(...), which contains the > ValueStack containing your objects. > > Peace, > Scott > > > > On Tue, May 19, 2009 at 7:59 AM, manub wrote: > >> >> Hi all, >> >> I'm trying to write a custom field validator which needs other fields to >> validate the field I need to validate. How can I pass field values (and >> not >> static params) to a field validator in the validation xml? I'm using >> Struts >> 2.1.6. >> >> Thank you. >> -- >> View this message in context: >> http://www.nabble.com/passing-form-parameters-to-a-custom-validator-tp23615918p23615918.html >> Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> - >> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >> > > -- View this message in context: http://www.nabble.com/passing-form-parameters-to-a-custom-validator-tp23615918p23651619.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: How to get request locale in OGNL?
invocation.getStack().findString(#attr.locale) On Thu, May 21, 2009 at 6:22 AM, Gordian Yuan wrote: > Hi, > > I want to know how to get request locale in OGNL? > > For now I use > value='#session.WW_TRANS_I18N_LOCALE?#session.WW_TRANS_I18N_LOCALE.toString():"zh_CN"'/> > > This must assume that the initial value is "zh_CN". > > So I need to know how to get request locale in OGNL. > > Thx > > Gordian Yuan >
Re: passing form parameters to a custom validator
Rather than pass this, that and the other parameter(s) to your validator, why not just retrieve what you need from inside the validator? You have the ActionInvocation passed to your doIntercept(...), which contains the ValueStack containing your objects. Peace, Scott On Tue, May 19, 2009 at 7:59 AM, manub wrote: > > Hi all, > > I'm trying to write a custom field validator which needs other fields to > validate the field I need to validate. How can I pass field values (and not > static params) to a field validator in the validation xml? I'm using Struts > 2.1.6. > > Thank you. > -- > View this message in context: > http://www.nabble.com/passing-form-parameters-to-a-custom-validator-tp23615918p23615918.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
How to get request locale in OGNL?
Hi, I want to know how to get request locale in OGNL? For now I use This must assume that the initial value is "zh_CN". So I need to know how to get request locale in OGNL. Thx Gordian Yuan
Re: Preload of database data?
You can prepare data by implemeting Preparable in your action On Tue, May 19, 2009 at 4:48 PM, Christian Benjamin Ries < christian_benjamin.r...@fh-bielefeld.de> wrote: > Hi there, > > I have a small site with some informations which are stored in a > database. A method for administrations reason is added to change the > content (names) of the datasets. > > Now, I will add these names to my navigation. > > I have a action like this: > > > ... > > > This action edits the content of the bean "System". > > I will add this bean content to all other actions in my navigation, but > I don't know the right way to solve this problem. Any suggestions? > > Thx! > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > >
Re: passing form parameters to a custom validator
2009/5/21 manub : > I think that this may work for the expression validator because you are > supplying an expression. I've been thinking about tag, with it you can set any field in your validator and it can be an OGNL expression. Regards -- Lukasz http://www.lenart.org.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: passing form parameters to a custom validator
I think that this may work for the expression validator because you are supplying an expression. Maybe I need to use an expression too, but I don't know how to evaluate it within my Java class for Validator. Lukasz Lenart wrote: > > 2009/5/20 manub : >> I've written a custom field validator, which needs other field values to >> validate his field. I need a way to pass that values to that field >> validator. > > Did you try to use param tag as below? > > > > $...@pl.org.lenart.ems.model.employeetype@.value() > != 'dd'} > error.employee.type.required > > > > > > > Regards > -- > Lukasz > http://www.lenart.org.pl/ > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > > -- View this message in context: http://www.nabble.com/passing-form-parameters-to-a-custom-validator-tp23615918p23649333.html Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org