Re: Multiple field with same name
I have solved the problem. The thread I referenced is correct. Franz On Fri, Aug 13, 2010 at 6:00 PM, Franz Wong franzw...@gmail.com wrote: I found the Type conversion page from struts official web site and I followed the Advanced example for indexed Lists and Maps, but I cannot get it work. Then I followed this thread [1]. However, my list only contains 1 null object. Franz [1] http://old.nabble.com/-S2--Beans-list-in-Dynamic-form-and-ParametersInterceptor-problem-td15016850.html On Fri, Aug 13, 2010 at 2:13 PM, Franz Wong franzw...@gmail.com wrote: Hi, I would like to show a list of user and enable the change of the name. I don't know if there is any mechanism which struts provided to do that. class User { private Long id; private String name; // getters and setters } form action=updateUser table s:iterator value=users tr td s:textfield name=name/ /td /tr /s:iterator /table s:submit/ /form Thanks. Franz
Multiple field with same name
Hi, I would like to show a list of user and enable the change of the name. I don't know if there is any mechanism which struts provided to do that. class User { private Long id; private String name; // getters and setters } form action=updateUser table s:iterator value=users tr td s:textfield name=name/ /td /tr /s:iterator /table s:submit/ /form Thanks. Franz
Re: Multiple field with same name
I found the Type conversion page from struts official web site and I followed the Advanced example for indexed Lists and Maps, but I cannot get it work. Then I followed this thread [1]. However, my list only contains 1 null object. Franz [1] http://old.nabble.com/-S2--Beans-list-in-Dynamic-form-and-ParametersInterceptor-problem-td15016850.html On Fri, Aug 13, 2010 at 2:13 PM, Franz Wong franzw...@gmail.com wrote: Hi, I would like to show a list of user and enable the change of the name. I don't know if there is any mechanism which struts provided to do that. class User { private Long id; private String name; // getters and setters } form action=updateUser table s:iterator value=users tr td s:textfield name=name/ /td /tr /s:iterator /table s:submit/ /form Thanks. Franz
Re: How do we repopulate controls when validation fails?
Thanks. It solves my problem :) Franz On Wed, Aug 11, 2010 at 10:11 PM, Alex Rodriguez Lopez alo...@flordeutopia.pt wrote: Don't know if this solves your problem, but maybe it helps to use the params-prepare-params trick, calling params interceptor twice, so you have your params ready before prepare(). You have an already configured stack, the paramsPrepareParamsStack From struts-default.xml: !-- An example of the paramsPrepareParams trick. This stack is exactly the same as the defaultStack, except that it includes one extra interceptor before the prepare interceptor: the params interceptor. This is useful for when you wish to apply parameters directly to an object that you wish to load externally (such as a DAO or database or service layer), but can't load that object until at least the ID parameter has been loaded. By loading the parameters twice, you can retrieve the object in the prepare() method, allowing the second params interceptor to apply the values on the object. -- interceptor-stack name=paramsPrepareParamsStack interceptor-ref name=exception/ interceptor-ref name=alias/ interceptor-ref name=i18n/ interceptor-ref name=checkbox/ interceptor-ref name=multiselect/ interceptor-ref name=params param name=excludeParamsdojo\..*,^struts\..*/param /interceptor-ref interceptor-ref name=servletConfig/ interceptor-ref name=prepare/ interceptor-ref name=chain/ interceptor-ref name=modelDriven/ interceptor-ref name=fileUpload/ interceptor-ref name=staticParams/ interceptor-ref name=actionMappingParams/ interceptor-ref name=params param name=excludeParamsdojo\..*,^struts\..*/param /interceptor-ref interceptor-ref name=conversionError/ interceptor-ref name=validation param name=excludeMethodsinput,back,cancel,browse/param /interceptor-ref interceptor-ref name=workflow param name=excludeMethodsinput,back,cancel,browse/param /interceptor-ref /interceptor-stack Hi, I have read the documentation How do we repopulate controls when validation fails [1]. I tried the action tag solution. However, when there is a validation error, the execute method of the action ins:action is not called. I don't choose the Preparable solution because the parameter required is not ready in the Prepare stage. (For the first time of visit, the parameter is set to default.) And I don't want to call the preparation twice in both execute and prepare. So what is the best way to repopulate controls for normal case and revisit after validation error? Should I abandon to validate the input in validate method? Thanks. Franz [1] http://struts.apache.org/2.x/docs/how-do-we-repopulate-controls-when-validation-fails.html - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
How do we repopulate controls when validation fails?
Hi, I have read the documentation How do we repopulate controls when validation fails [1]. I tried the action tag solution. However, when there is a validation error, the execute method of the action in s:action is not called. I don't choose the Preparable solution because the parameter required is not ready in the Prepare stage. (For the first time of visit, the parameter is set to default.) And I don't want to call the preparation twice in both execute and prepare. So what is the best way to repopulate controls for normal case and revisit after validation error? Should I abandon to validate the input in validate method? Thanks. Franz [1] http://struts.apache.org/2.x/docs/how-do-we-repopulate-controls-when-validation-fails.html
Get i18n text problem
Hi group, In the jsp page, I have a page scope variable title. This variable stores the key of the resource bundle. I can print the value by %= title %. However, I am not able to use it with s:text/. I have tried s:text name=${title}/ or s:text name=%= title %/. But both of them do not work. Thanks. Franz
Clear ThreadLocal of ActionContext
Hi, I would like to ask is there any mechanism clearing ThreadLocal of ActionContext by struts? As I know, there are some issues when ThreadLocal is used with thread pool. Reference : http://weblogs.java.net/blog/jjviana/archive/2010/06/09/dealing-glassfish-301-memory-leak-or-threadlocal-thread-pool-bad-ide Thanks Franz
Parse url parameter
Hi group, Suppose I have an URL with parameters (e.g. http://localhost:8080/myApp/action/myAction/user/name/Peter). I would like to map those parameters in the following way. class MyAction { private String searchType; // user private String searchMethod; // name private String searchData // Peter } Is there any Action class can parse the parameters into properties of Action? Thanks Franz
Strange behaviour on i18n
Hi, I have an i18n web site with struts 2. I don't know why the i18n text is not loaded properly. I expect 檢索詞不能空白 (Chinese characters), but it turns out 檢索詞不不能空白. But if I make any change on the html (e.g. the order of attributes or remove some elements), the text is loaded without any problem. Thanks. Franz Problem html code : input type=button value=s:text name=search/ onClick=searchButtonClick('s:text name=search.searchTermCannotBeEmpty /');/ (HTML : input type=button value=檢索 onClick=searchButtonClick('檢索詞不不能空白');/) However, the following html code works fine. input type=button onClick=searchButtonClick('s:text name=search.searchTermCannotBeEmpty /'); value=s:text name=search// (HTML : input type=button onClick=searchButtonClick('檢索詞不能空白'); value=檢索/) Properties file : search.searchMethod=檢索方法 search.searchMethod.Title=書名 search.searchMethod.Author=著者 search.searchMethod.Subject=主題 search.searchMethod.Series=叢書 search.searchMethod.TitleKeyword=書名關鍵詞 search.searchMethod.AuthorKeyword=著者關鍵詞 search.searchMethod.SubjectKeyword=主題關鍵詞 search.searchTerm=檢索詞 search.searchTermCannotBeEmpty=檢索詞不能空白 search=檢索 Here is the whole jsp file. %...@taglib prefix=s uri=/struts-tags % select id=searchMethod option value=Titles:text name=search.searchMethod.Title//option option value=Authors:text name=search.searchMethod.Author//option option value=Subjects:text name=search.searchMethod.Subject//option option value=Seriess:text name=search.searchMethod.Series//option option value=TitleKeywords:text name=search.searchMethod.TitleKeyword//option option value=AuthorKeywords:text name=search.searchMethod.AuthorKeyword//option option value=SubjectKeywords:text name=search.searchMethod.SubjectKeyword//option /select input type=text id=searchTerm size=30 class=searchTermEmpty value=s:text name=search.searchTerm / onFocus=searchTermOnFocus(this, 's:text name=search.searchTerm /'); onBlur=searchTermOnBlur(this, 's:text name=search.searchTerm /');/ input type=button value=s:text name=search/ onClick=searchButtonClick('s:text name=search.searchTermCannotBeEmpty /');/ span id=searchResult/span
Display ActionMessage added from different action
Hi, I am using Struts 2. I have a page which contains 2 forms. Each form corresponds to different Actions (Action B / C). The action adds ActionMessage and redirects back to the original page. I would like to display the ActionMessage in the form which triggered the Action. How do I perform this in Struts? As I see, addActionMessage method only accepts single string as parameter. Action A = Main JSP (Containing 2 Forms) = Action B / C (Both action adds ActionMessage) = Action A Thanks. Franz