Struts 2 and an array of textfields
How do i handle an array of textfields? I have a form from which the user must check a list of checkboxes and enter some text in a textfield that must be associated with a textbox My action extends ActionSupport and i'm using s2 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[S2]ActionSupport set parameters question.
I'm having trouble understanding how ActionSupport works. I've extended ActionSupport to handle a form page. If the from contains errors (ie: i have an amount field mapped like s:text name=invoice.amount/ and the user types in asdf) the action mapped to result type execute is never called and, even though the form si set to not perform validation. I want to handle errors trough code (rather than providing an xml for it). What do i need to override to handle this type or errors? -- Regards, Eugen Stoianovici - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2]ActionSupport set parameters question.
Thank you, it's just what i needed David Harland wrote: Add something like this to your action public void validate() { User user = getUser(); if (StringUtils.isBlank(user.getName())) { addActionError(getText(user.name.empty)); } if (StringUtils.isBlank(user.getAddress())) { addActionError(getText(user.address.empty)); } } Have a look at http://today.java.net/pub/a/today/2006/01/19/webwork-validation.html --- Eugen Stoianovici [EMAIL PROTECTED] wrote: I'm having trouble understanding how ActionSupport works. I've extended ActionSupport to handle a form page. If the from contains errors (ie: i have an amount field mapped like s:text name=invoice.amount/ and the user types in asdf) the action mapped to result type execute is never called and, even though the form si set to not perform validation. I want to handle errors trough code (rather than providing an xml for it). What do i need to override to handle this type or errors? -- Regards, Eugen Stoianovici - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Regards, Eugen Stoianovici - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[s2]struts-2-spring-2-jpa-ajax tutorial
I've started learning struts based on this tutorial which (from my limited experience) is a good starting point. There's on problem for me though. It gets frustrating implementing all my persistence related calls in a service class. Is there a way to instantiate my action classes with an EntityManager, so that i can perform simple persistence related jobs directly in my actions? ... Is this a violation of struts framework concepts? Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[S2] action mappings help
I'm trying to create an index with an action mapped to it for a subfolder in my webapp. The ideea was to create a index.jsp file that has: jsp:forward page=/myapp/subfolder/welcome.action/ so it redirects me to a mapped action. The problem is that even though the url is correct, i get a The requested resource (/myapp/subfolder/welcome.action) is not available from my server. If i point my browser to http://website/myapp/subfolder/welcome.action (ie: if i type this in) everything works out just fine. What am i doing wrong? Thanks Eugen Stoianovici - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] action mappings help
Thanks, I added dispatcherREQUEST/dispatcher dispatcherREDIRECT/dispatcher in my web.xml file for filter-mapping. Which made perfect sense right after i read it. Cory D. Wiles wrote: If you are trying to truly redirect then the below line is your problem. It is trying to forward not redirect. jsp:forward page=/myapp/subfolder/welcome.action/ Use: % String redirectAction = /myapp/subfolder/welcome.action; response.sendRedirect(redirectAction); % On 9/19/07, Eugen Stoianovici [EMAIL PROTECTED] wrote: I'm trying to create an index with an action mapped to it for a subfolder in my webapp. The ideea was to create a index.jsp file that has: jsp:forward page=/myapp/subfolder/welcome.action/ so it redirects me to a mapped action. The problem is that even though the url is correct, i get a The requested resource (/myapp/subfolder/welcome.action) is not available from my server. If i point my browser to http://website/myapp/subfolder/welcome.action (ie: if i type this in) everything works out just fine. What am i doing wrong? Thanks Eugen Stoianovici - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JAAS struts 2 Tutorial?
I would like a tutorial on integrating jaas in struts2 too. Or rather than a tutorial, i would like to see some working code. I've done a lot of reading (i'm new to java web applications, it's been only a month since i've started) and i have some understanding on how this should work but i just can't picture it yet in a real app. I know I'm not being helpful here, sorry. But if anyone wants to write a tutorial on this, it would be greatly appreciated regards Eugen Stoianovici Muhammad Momin Rashid wrote: Hello Tom, Thanks for your continued input. The application isn't simple, it is a J2EE application which will serve a large number of users (users will be using Web Browser or Mobile Device to access the application). Based on the help I got on this list, I have been successful in setting up JAAS and authenticating the user. Now I am just not sure if the user credentials are being kept. Following is the code I wrote which processes the user's login. Can you see what I am missing? I have placed the following code in the execute method of my action, perhaps it isn't the right place? Subject subject; Set principalList; String returnValue = SUCCESS; try { SecurityAssociationHandler handler = new SecurityAssociationHandler(); SimplePrincipal user = new SimplePrincipal(username); handler.setSecurityInfo(user, password.toCharArray()); LoginContext loginContext = new LoginContext(ContentPlatform, (CallbackHandler) handler); loginContext.login(); subject = loginContext.getSubject(); principalList = subject.getPrincipals(); principalList.add(user); System.out.println(o0o0o subject: + subject); System.out.println(o0o0o principle: + principalList); } catch (LoginException e) { e.printStackTrace(); returnValue = ERROR; } return returnValue; Regards, Muhammad Momin Rashid. tom tom wrote: If it's simple application, you dont need JAAS, You can do it via just session management isnt it? You might need user, role, user-role threee tables on database thats it :) If you are using Application server like Jboss, the server itself got inbuilt features, which is altogether a different discussion. If the application is simple, do not make it complicated, we use JASS with CAS central authentication service which provided SSO features. hope this helps --- Muhammad Momin Rashid [EMAIL PROTECTED] wrote: Hello tom, I am building a J2EE application, that is going to be viewed using Web Browser and Mobile Devices. I am trying to implement security so that only a logged in user with the correct role can access the different parts of the application e.g. a non-logged in user can only access the public information, a logged in user can access his private data, and an logged in admin user can access the admin console. Regards, Muhammad Momin Rashid. tom tom wrote: what exactly you are trying to do? --- Muhammad Momin Rashid [EMAIL PROTECTED] wrote: Hello Everyone, I am looking for a tutorial for integrating JAAS into my Struts 2 + Hibernate Application. Can anyone point me to the right resources? Is JAAS the best way to go, or there are better alternates? If anyone thinks there are better alternates, can you provide me with the links to relevant tutorials? Regards, Muhammad Momin Rashid. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Luggage? GPS? Comic books? Check out fitting gifts for grads at Yahoo! Search http://search.yahoo.com/search?fr=oni_on_mailp=graduation+giftscs=bz - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Be a better Globetrotter. Get better travel answers from someone who knows. Yahoo! Answers - Check it out. http://answers.yahoo.com/dir/?link=listsid=396545469 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
s:property/ and number format
I want to display a number (double) into a jsp using a certain format (2 decimals). What's the best way to do it? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[S2] Integrating with springframework and tiles
I'm using using struts 2.0.9 with springframework 2.0.6 and i want to use tiles as a template engine. Now in struts1 i would use org.apache.struts.tiles.xmlDefinition.I18nFactorySet to initialize the org.springframework.web.servlet.view.tiles.TilesConfigurer but there's no such class in struts2. Is there a replacement? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] Integrating with springframework and tiles
wouldn't this affect the spring listener? George Dadulescu wrote: Just add the tile listener in the web.xml file of your application and set a tiles result type in the struts.xml file. On 8/31/07, Eugen Stoianovici [EMAIL PROTECTED] wrote: I'm using using struts 2.0.9 with springframework 2.0.6 and i want to use tiles as a template engine. Now in struts1 i would use org.apache.struts.tiles.xmlDefinition.I18nFactorySet to initialize the org.springframework.web.servlet.view.tiles.TilesConfigurer but there's no such class in struts2. Is there a replacement? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2][Tabbed panel] posting data from one tab
Alvaro Sanchez-Mariscal wrote: Hi, I've done the same using topics: 1) Publish on a topic after the request is executed (eg, notifyTopics=/submit in the s:submit). 2) Register to the same topic in the s:div corresponding to the tab (eg, listenTopics=/submit in the s:div). Alvaro. Can you give me an example? what i did was: the master file: (the one where i define the tabbedpanel) s:tabbedPanel id=tabbedpanel s:div id=vendor label=Vendor href=%{#vendor_tab} theme=ajax / s:div id=shipment label=Shipment href=%{#shipment_tab} theme=ajax / s:div id=products label=Products href=%{#products_tab} theme=ajax listenTopics=addProduct / /s:tabbedPanel the add product form: s:form action=addproduct validate=true s:textfield id=description name=product.description label=Description / s:textfield id=quantity name=product.quantity label=Quantity / s:textfield id=taxrate name=product.taxRate label=Tax Rate / s:textfield id=unitprice name=product.unitPrice label=Unit Price / s:submit value=Add notifyTopics=addProduct / /s:form Now, is there anything else i need to do in my action class or in those two jsp's? Because it doesn't work like this :( - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2][Tabbed panel] posting data from one tab
Alvaro Sanchez-Mariscal wrote: Try prepending an slash, ie, /addProduct. Without it, it also didn't worked to me. Also, what happens exactly? Javascript errors? Have you tried inspecting it with firebug? Alvaro. On 8/19/07, Eugen Stoianovici [EMAIL PROTECTED] wrote: I've tried it with /addProduct and i've also moved the products pane to to the addpo.jsp page (so now, it isn't a remote pane). There's nothing wrong happening, it just takes me to the first tab after i press the add button. I mean: the data gets posted, everything is in place...it's just that it displays the first tab instead of the 3th. The url changes from addpo.jsp to addproduct.action. Is this a problem? Here's the code: action mapping: action name=addproduct class=addPoAction method=addProduct result/popages/addpo.jsp/result result name=input/popages/addpo.jsp/result /action The jsp: !-- addpo.jsp-- s:tabbedPanel id=tabbedpanel s:div id=vendor label=Vendor href=%{#vendor_tab} theme=ajax / s:div id=shipment label=Shipment href=%{#shipment_tab} theme=ajax / !-- the form-- s:div id=products label=Products theme=ajax listenTopics=/addProduct div style=border-style: solid pAdd new product to list/p s:form action=addproduct validate=true s:textfield id=description name=product.description label=Description / s:textfield id=quantity name=product.quantity label=Quantity / s:textfield id=taxrate name=product.taxRate label=Tax Rate / s:textfield id=unitprice name=product.unitPrice label=Unit Price / s:submit value=Add notifyTopics=/addProduct / /s:form/div /s:div /s:tabbedPanel jsp warnings: (there are no errors): Warning: Unknown property '_zoom'. Declaration dropped. Source File: http://localhost:8080/POPSWeb/addproduct.action Line: 7 Warning: Unknown property '_margin-bottom'. Declaration dropped. Source File: http://localhost:8080/POPSWeb/addproduct.action Line: 24 Warning: Error in parsing value for property 'display'. Declaration dropped. Source File: http://localhost:8080/POPSWeb/addproduct.action Line: 47 Warning: Expected ':' but found 'none'. Declaration dropped. Source File: http://localhost:8080/POPSWeb/addproduct.action Line: 0 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: action mappings help
Laurie Harper wrote: Eugen Stoianovici wrote: I'm using struts 2.0.9. Where do i read about action mappings and how to configure them? In the Struts2 documentation of course ;-) These pointers may help: http://struts.apache.org/2.x/docs/action-configuration.html http://struts.apache.org/2.x/docs/result-types.html Is there any detailed documentation? Right now i'm doing something like this...but i don't really know why i need the result name=input tag and couldn't find any info about it on my own: action name=prepvendor class=addPoAction method=prepVendor result/popages/selvendor.jsp/result result name=input/popages/selvendor.jsp/result /action You need a result named 'input' in at least the following situations: * you return 'input' as the result from your action method ;-) * you're using validation and validation fails; Struts will automatically forward to the 'input' result so the user can correct the data they entered and re-submit * the same may also be true for conversion errors In general, for an action mapping that is going to retrieve data or just display a page or form, you don't need an input result, and when you do use an input result it should generally be pointing at such a mapping. L. Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[S2] session question
how do i get a handle to Session / Request from an action implementing import com.opensymphony.xwork2.Preparable;? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] session question
Laurie Harper wrote: Eugen Stoianovici wrote: how do i get a handle to Session / Request from an action implementing import com.opensymphony.xwork2.Preparable;? http://struts.apache.org/2.x/docs/how-do-we-get-access-to-the-session.html http://struts.apache.org/2.x/docs/how-can-we-access-the-httpservletrequest.html L. Thanks. I guess i should really read the struts2 docs before asking stupid questions :). - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
struts irc channel?
Is there a struts support channel?(other than the one on irc.freenode.net which only has 4 or 5 members) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[S2][Tabbed panel] posting data from one tab
i have a tabbedpanel which displays several tabs one of which contains a form. How do i turn back to that tab after i've pressed the submit button on that form? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
action mappings help
I'm using struts 2.0.9. Where do i read about action mappings and how to configure them? Is there any detailed documentation? Right now i'm doing something like this...but i don't really know why i need the result name=input tag and couldn't find any info about it on my own: action name=prepvendor class=addPoAction method=prepVendor result/popages/selvendor.jsp/result result name=input/popages/selvendor.jsp/result /action thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[action question]
can i forward an action to another action using the result tag in action mappings? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [action question]
Dave Newton wrote: can i forward an action to another action using the result tag in action mappings? Yes; result type is redirect-action [1] ([2] for all types). See [3] regarding action mapping configuration. d. [1] http://struts.apache.org/2.x/docs/redirect-action-result.html [2] http://struts.apache.org/2.x/docs/result-types.html [3] http://struts.apache.org/2.x/docs/action-configuration.html thank you. that's exactly what i needed - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
tomcat 5.5 authentication question
I'm very new to struts (and java for that matter) so my question might be stupid but here goes: I have an application that is based on companies and employees. Each employee may have a single company. Also each employee has a user (which is used by tomcat for authentication/authorization) and i want to set some session values after a login (like current company and current employee). Since I can't intercept the login form (which goes to j_security_check) where should i put the code for setting those session values? Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
struts 2.0.8 problem implementing filter
i'm trying to use a custom filter to implement authorization and i can't get the damned thing to work (i'm an absolute beginner, be warned). i'm using struts2.0.8 with tomcat 5.5 my doFilter method looks like this public class AuthorizationFilter implements Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse res = (HttpServletResponse) response; HttpSession session = req.getSession(); Employee employee = (Employee) session.getAttribute(user); boolean hasRole = false; if(employee!=null){ for (int i = 0; i roleNames.length; i++) { if (employee.hasRole(roleNames[i])) { hasRole = true; break; } } } if (hasRole) { chain.doFilter(request, response); } else { req.getRequestDispatcher(onErrorUrl).forward(req, res); } } } the browser reports: (line 47 is req.getRequestDispatcher(onErrorUrl).forward(req, res); ) *type* Exception report *message* *description* _The server encountered an internal error () that prevented it from fulfilling this request._ *exception* org.apache.jasper.JasperException org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:476) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) security.AuthorizationFilter.doFilter(AuthorizationFilter.java:47) *root cause* java.lang.NullPointerException org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:58) org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:52) org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:49) org.apache.jsp.index_jsp._jspx_meth_s_005furl_005f0(index_jsp.java:102) org.apache.jsp.index_jsp._jspService(index_jsp.java:62) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) security.AuthorizationFilter.doFilter(AuthorizationFilter.java:47) * *__ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
struts2.0.8 javax.servlet.Filter implementation problem
i'm trying to use a custom filter to implement authorization and i can't get the damned thing to work (i'm an absolute beginner, be warned). i'm using struts2.0.8 with tomcat 5.5 my doFilter method looks like this public class AuthorizationFilter implements Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest req = (HttpServletRequest) request; HttpServletResponse res = (HttpServletResponse) response; HttpSession session = req.getSession(); Employee employee = (Employee) session.getAttribute(user); boolean hasRole = false; if(employee!=null){ for (int i = 0; i roleNames.length; i++) { if (employee.hasRole(roleNames[i])) { hasRole = true; break; } } } if (hasRole) { chain.doFilter(request, response); } else { req.getRequestDispatcher(onErrorUrl).forward(req, res); } } } the browser reports: (line 47 is req.getRequestDispatcher(onErrorUrl).forward(req, res); ) *type* Exception report *message* *description* _The server encountered an internal error () that prevented it from fulfilling this request._ *exception* org.apache.jasper.JasperException org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:476) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) security.AuthorizationFilter.doFilter(AuthorizationFilter.java:47) *root cause* java.lang.NullPointerException org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:58) org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:52) org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:49) org.apache.jsp.index_jsp._jspx_meth_s_005furl_005f0(index_jsp.java:102) org.apache.jsp.index_jsp._jspService(index_jsp.java:62) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) security.AuthorizationFilter.doFilter(AuthorizationFilter.java:47) * *__ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]