Re: Unit Testing Actions with Annotation based validation in Struts 2.1.6
I've figured how to do it! You need to use the container properly to populate all the fields with @Inject annotated setters. It's another reason why I don't like auto-wiring. I know it's powerful and when you're familiar with the codebase it's simple but it makes stepping through the code a nightmare as object creation and population is done by voodoo. If anyones is interested let me know and I'll post the code. Martin -- View this message in context: http://www.nabble.com/Unit-Testing-Actions-with-Annotation-based-validation-in-Struts-2.1.6-tp25800676p25869302.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: action class is a part of controller or model; and what about formBean
Well i would say, tha action implementation (action class) is the controller, formBean is in one way the interface between view and controller and model is implementation of some third part (f.e. hibernate)... Thats my view of the 'story'. If i'm wrong, please correct me. Gregor Arindam Rajbanshi wrote: ya, i understand, but action class is a part of controller or model. and formBean is a part of model or controller. On Mon, Oct 12, 2009 at 3:59 PM, Terry Gardner terry.gard...@sun.comwrote: Broadly speaking, the Controller is the filter, the Model is the action, and the result leads to the View. On Oct 12, 2009, at 5:58 AM, Arindam Rajbanshi wrote: i am doing struts 1.2 . Please tell me action is a part of controller or model. and formbean is a part of controller or model. even in the apache document http://struts.apache.org/1.x/userGuide/index.html tehy mentionde bormbean in Building Model Components and Building Controller Components in two places and action in Building Controller Components please clear my doubt. -- terry.gard...@sun.com Blog: http://ff1959.wordpress.com http://www.directory-server.org Mobile: 404 925 6385 -- Gregor Marinšek TIS d.o.o. Ljubljanska 9, Maribor e-mail: gmarin...@tis.si http://www.tis.si GSM: (+386) 040 730 015 - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: How to get value of tag attribute from OGNL?
I have such custom JSP tag file: /WEB-INF/tags/formField.tag -- %@ taglib prefix=s uri=/struts-tags % %@ tag language=java pageEncoding=UTF-8 % %@ attribute name=fieldName % %@ attribute name=inputId % %@ attribute name=label % %@ attribute name=labelKey % %@ attribute name=required % s:set var=inputId value=%{#attr.inputId != null ? #attr.inputId : (#attr.fieldName != null ? #attr.fieldName : '')}/ s:set var=label value=%{#attr.labelKey != null ? getText(#attr.labelKey) : (#attr.label != null ? #attr.label : '')}/ s:set var=fieldErrors value=%{fieldErrors[#attr.fieldName]}/ s:set var=hasFieldErrors value=%{#fieldErrors != null #fieldErrors.size 0}/ div class=wwgrp s:property value=%{#hasFieldErrors ? 'HasFieldErrors' : ''}/ table class=HiddenTable tr td class=wwlbl s:if test=%{!isBlank(#label)} label class=label for=s:property value=%{#inputId}/ s:if test=%{#attr.required}*/s:if s:property value=%{#label} escape=false/:/label /s:if /td td class=wwctrl jsp:doBody/ s:if test=%{#hasFieldErrors} ul class=wwerr s:iterator var=error value=%{#fieldErrors} li class=errorMessage s:property value=%{#error} escape=false//li /s:iterator /ul /s:if /td /tr /table /div -- And here is the part of my login.jsp that uses this custom tag: -- %@ taglib prefix=t tagdir=/WEB-INF/tags % ... s:form action=login ... t:formField fieldName=password required=true labelKey=msgkey.label.password input type=password id=password name=password/ TODO: Forgot your password? /t:formField ... /s:form -- Suppose action has a property 'fieldName' and I need to get value of a tag attribute w/ the same name. I get tag atribute using s:property value=%{#attr.fieldName}/. The issue here is: if jsp page that uses this custom tag does not provide value for 'fieldName' attribute, then s:property value=%{#attr.fieldName}/ will return value of action property 'fieldName'. I did not found where jsp tag stored its attribute, but it seemed like in PageContext. I tried to get PageContext, but ActionContext returns 'null'. Here is my Java code: PageContext pageContext = ServletActionContext.getPageContext(); if (pageContext != null) { log.debug(pageContext.findAttribute('fieldName'): + pageContext.findAttribute(fieldName)); } Musachy Barroso wrote: I am not sure I understand what you mean. Is someTagAttribute set in the context by your custom tag? musachy On Mon, Oct 12, 2009 at 2:57 PM, Alex Siman aleksandr.si...@gmail.com wrote: I have created JSP file tag as it is described here http://java.sun.com/javaee/5/docs/tutorial/doc/bnama.html To get value of tag attribute 'someTagAttribute' I use this code: s:property value=%{#attr.someTagAttribute}/ OGNL context works fine within this file tag. But I realized that if there will be an action property with the same name 'someTagAttribute' and value for tag attribute will not be set, then the above code will return value of action property as if it is the value of tag attribute. How to get value of tag attribute directly from OGNL? -- View this message in context: http://www.nabble.com/How-to-get-value-of-tag-attribute-from-OGNL--tp25862967p25862967.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 -- 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 -- View this message in context: http://www.nabble.com/How-to-get-value-of-tag-attribute-from-OGNL--tp25862967p25871222.html Sent from the Struts - User mailing list archive at Nabble.com.
Conversion problem for bi-dimensional Lists and Arrays
Hi all, I want to send a bidimensional List and/or a bidimensional array from my application's view to the action. For example, I have a generixMatrix object in the action (with getters and setters of course). The genericMatrix should be able to hold any kind of object. I want to set a 'Currency' object's 'value' field from the view, using an input name=OGNL expression value=theValue My problem is that i cannot address the Currency object properly with OGNL, or Struts does a bad type conversion. I tried to represent a currencyMatrix that holds Currency objects 1) In the action: ListListCurrency currencyMatrix In the view: currencyMatrix[0][1].value (currencyMatrix[0])[1].value currencyMatrix.get(0).get(1) None of these are working. I debugged and noticed that currencyMatrix gets initialized, but instead of RowDTOCurrency elements, all its elements are null. 2) In the action ListRowDTOCurrency currencyMatrix where RowDTOT represents a row, having a field ListT rowElements In the view: currencyMatrix[0].rowElements[1].value Same as above, currencyMatrix is filled with null elements 3)In the action: ListcurrencyRowDTO currencyMatrix and RowDTO has a typed list ListCurrency currencyRowElements. It works, but it does not help me. This forces me to create a new row object each time, like personRowDTO, anotherRowDTO etc. Struts2 documentation specifies that the Struts 2 type conversion mechanism can use generics-based typing to learn the correct target type for the conversions, but I think it defects when having nested generic types. I also tried using a bidimensional array like Currency[][] but again I cannot find a way to reffer to it with OGNL. I am open to any suggestions. To make a long story short, all I need is a sollution for a matrix-like object that can hold any type of object Thanks you in advance -- Damian - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
how to add multiple addon rows in struts..urgert please
Hi all please let me know how we can add multiple rows like he want to add multiple Mobile numbers in the jsp page when he want to submit in struts. page has a filed mobile no. to enetre then beside add another Mobile no. and edit the No. please replay quickly... -- Thanks Regards Swathi
Re: how to add multiple addon rows in struts..urgert please
wrong word correct field not filed On Tue, Oct 13, 2009 at 6:20 PM, swathi reddy swathi23.re...@gmail.comwrote: Hi all please let me know how we can add multiple rows like he want to add multiple Mobile numbers in the jsp page when he want to submit in struts. page has a filed mobile no. to enetre then beside add another Mobile no. and edit the No. please replay quickly... -- Thanks Regards Swathi -- Thanks Regards Swathi
Re: how to add multiple addon rows in struts..urgert please
You need to declare ur variable like an array of string, numbers... ArrayListString mobiles and then in ur jsp code u just need to create differents input all of them with the same name mobiles dont forget the get and set for the property... De: swathi reddy swathi23.re...@gmail.com Para: user@struts.apache.org Enviado: mar, octubre 13, 2009 9:50:01 AM Asunto: how to add multiple addon rows in struts..urgert please Hi all please let me know how we can add multiple rows like he want to add multiple Mobile numbers in the jsp page when he want to submit in struts. page has a filed mobile no. to enetre then beside add another Mobile no. and edit the No. please replay quickly... -- Thanks Regards Swathi ¡Obtén la mejor experiencia en la web! Descarga gratis el nuevo Internet Explorer 8. http://downloads.yahoo.com/ieak8/?l=e1
Re: how to add multiple addon rows in struts..urgert please
Actuall i am strucked at design while we we want to add one more number ,he will click at add one more number then previous one need to be shouln as label and the new empty mobile no. text field should display. 2009/10/13 Mileidys González Prieto mileid...@yahoo.com You need to declare ur variable like an array of string, numbers... ArrayListString mobiles and then in ur jsp code u just need to create differents input all of them with the same name mobiles dont forget the get and set for the property... De: swathi reddy swathi23.re...@gmail.com Para: user@struts.apache.org Enviado: mar, octubre 13, 2009 9:50:01 AM Asunto: how to add multiple addon rows in struts..urgert please Hi all please let me know how we can add multiple rows like he want to add multiple Mobile numbers in the jsp page when he want to submit in struts. page has a filed mobile no. to enetre then beside add another Mobile no. and edit the No. please replay quickly... -- Thanks Regards Swathi ¡Obtén la mejor experiencia en la web! Descarga gratis el nuevo Internet Explorer 8. http://downloads.yahoo.com/ieak8/?l=e1 -- Thanks Regards Swathi
Re: How to get value of tag attribute from OGNL?
OK, I figured out how to get value of tag attribute in JSP: %= jspContext.getAttribute(fieldName, PageContext.PAGE_SCOPE) % Now I need to put this value into some OGNL variable, say '#ognlFieldName', to get access to this value from Struts2 tags. So, how to get access to jspContext from OGNL or at least Java code? -- View this message in context: http://www.nabble.com/How-to-get-value-of-tag-attribute-from-OGNL--tp25862967p25872856.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 value of tag attribute from OGNL?
Why not use this? http://struts.apache.org/2.1.6/docs/set.html -Original Message- From: Alex Siman [mailto:aleksandr.si...@gmail.com] Sent: Tuesday, October 13, 2009 9:25 AM To: user@struts.apache.org Subject: Re: How to get value of tag attribute from OGNL? OK, I figured out how to get value of tag attribute in JSP: %= jspContext.getAttribute(fieldName, PageContext.PAGE_SCOPE) % Now I need to put this value into some OGNL variable, say '#ognlFieldName', to get access to this value from Struts2 tags. So, how to get access to jspContext from OGNL or at least Java code? -- View this message in context: http://www.nabble.com/How-to-get-value-of- tag-attribute-from-OGNL--tp25862967p25872856.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 - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: How to get value of tag attribute from OGNL?
Did you mean this variant?: s:set var=ognlFieldName value='%{\%= jspContext.getAttribute(fieldName, PageContext.PAGE_SCOPE) %\}'/ This code does NOT work. So the question still open. Mike Baranski-2 wrote: Why not use this? http://struts.apache.org/2.1.6/docs/set.html -Original Message- From: Alex Siman [mailto:aleksandr.si...@gmail.com] Sent: Tuesday, October 13, 2009 9:25 AM To: user@struts.apache.org Subject: Re: How to get value of tag attribute from OGNL? OK, I figured out how to get value of tag attribute in JSP: %= jspContext.getAttribute(fieldName, PageContext.PAGE_SCOPE) % Now I need to put this value into some OGNL variable, say '#ognlFieldName', to get access to this value from Struts2 tags. So, how to get access to jspContext from OGNL or at least Java code? -- View this message in context: http://www.nabble.com/How-to-get-value-of- tag-attribute-from-OGNL--tp25862967p25872856.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 - 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/How-to-get-value-of-tag-attribute-from-OGNL--tp25862967p25873140.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
Why is PageContext null?
I do try to get PageContext inside action in a such way: ServletActionContext.getPageContext(); and it is null. Why? -- View this message in context: http://www.nabble.com/Why-is-PageContext-null--tp25873385p25873385.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 value of tag attribute from OGNL?
The answer is easier if this .tag file contains no recursive calls. The issue is that the .tag file receives attributes through jstl-el, not ognl. You can use the jstl-el c:set tag to promote that value into a namespace that's also accessible from ognl. Alex Siman wrote: /WEB-INF/tags/formField.tag -- %@ attribute name=fieldName % c:set var=fieldNameInTag scope=request value=${fieldName}/ s:property value=%{#request.fieldNameInTag}/ -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
localization properties files working in WEB-INF/classes and not in WEB-INF/lib/NAME.jar
Hi there, I am facing a strange problem. My properties files work fine when I put them unjarred in /WEB-INF/classes/com/mypackage/package_en.properties /WEB-INF/classes/com/mypackage/package_en.properties but struts2 actions and tags (s:text) won't find them if I include them in the same jar file with the actions: /WEB-INF/lib/myActions.jar I name them package_LANGUAGE.properties The weird thing is that they do work in /WEB-INF/classes dir. Thanks for any ideas on what I might be missing, Ignacio -- View this message in context: http://www.nabble.com/localization-properties-files-working-in-WEB-INF-classes-and-not-in-WEB-INF-lib-NAME.jar-tp25873486p25873486.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: Portlet form action parameters doubles the namespace of actions
I reconfigured the project not to use the convention plugin and using the good old xml-configuration. But the problem persists. I'll try to dig into what might be causing this. Is anyone looking actively at the portlet plugin? Can anyone give me advice on development tools for debugging portlets? The portal I'm working in now i kind of heavy... 2009/10/8 Leonard Broman firepi...@gmail.com: Hi! I'm building a simple portlet using struts 2.1.8 with convention and the portlet plugin. I have an issue where is seems that the action url (submit url) has a doubled namespace like: Here's the query string: ?struts.portlet.mode=configdynamicAttributes=%7B%7Dsv.mode=configstruts.portlet.action=/email/config/email/config/configtemplateDir=templatetheme=simple From this I can see that it gets the /email/config/email/config namespace instead of just /email/config. Not unexpected, struts throws an exception about action not found when submit is clicked. This is only while running as a portlet, as webapp (test) everything works fine. Anyone has any clues? Leonard broman - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Why is PageContext null?
that should be available inside tags only, not actions..I think. On Tue, Oct 13, 2009 at 6:57 AM, Alex Siman aleksandr.si...@gmail.com wrote: I do try to get PageContext inside action in a such way: ServletActionContext.getPageContext(); and it is null. Why? -- View this message in context: http://www.nabble.com/Why-is-PageContext-null--tp25873385p25873385.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 -- 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: Why is PageContext null?
OK, let it be so. Musachy Barroso wrote: that should be available inside tags only, not actions..I think. On Tue, Oct 13, 2009 at 6:57 AM, Alex Siman aleksandr.si...@gmail.com wrote: I do try to get PageContext inside action in a such way: ServletActionContext.getPageContext(); and it is null. Why? -- View this message in context: http://www.nabble.com/Why-is-PageContext-null--tp25873385p25873385.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 -- 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 -- View this message in context: http://www.nabble.com/Why-is-PageContext-null--tp25873385p25875240.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
Passing List with Redirect
Hi All I'm wondering if theres a way to pass a list of values as a parameter in a redirectAction. For instance: action name=WorkAction class=test.WorkAction result name=success type=redirectAction param name=actionNameViewAction/param param name=myList${myList}/param param name=myProperty${myProperty}/param /result /action In this case, myList is an array list that is populated in WorkAction. ViewAction then has a setter for an Array List of the same name. myProperty is just a string. This doesn't work as it stands, I get a string representation of the array instead of the array passed. So in the ViewAction instead of a 2 item array, I get a single item array with a string like: [TEST A, TEST B] While this is certainly parsable, I was wondering if theres a way to handle this with something already built into struts. I'm also aware that it's possible to solve this using the session, but I was curious if theres a way to avoid doing it that way. Thanks, Tim O - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Changing the border color of a text field
You could use 'addFieldError' in your action class for the zipcode field that contains the error. Then use the 'cssErrorClass' attribute in the s:textfield tag to change the display of the 'error' textfield. Each of your textfields will have to have a unique name in order to add the field error. Eg: addFieldError(zipcode1); s:textfield name='zipcode1' cssErrorClass='errorClass' / The errorClass would have CSS attributes to change the color, etc. On 10/12/09, Alex Siman aleksandr.si...@gmail.com wrote: Try to add next code: s:set var=zipCodeErrors value=%{fieldErrors['zipCode[' + #rowstatus.index + ']']}/ s:textfield ... cssStyle=%{(#zipCodeErrors != null #zipCodeErrors.size 0) ? 'border: 1px solid red;' : ''} ... / james billa wrote: Hi, I have a field called Preferred Zip codes : . The user is provided with 10 textfields for this to enter. He may enter 1 or more and submit the form. If any of the zip codes that he entered is not in my database, I need to change the border color of that textfield containing incorrect zip code alone to red and show the form back to user. How do I do this using Struts 2.1.6. I already know in my action class about the incorrect field. In JSP I have constructed text fields using s:iterator with value as dummy string array of size 10. Everything looks good. How to connect the error in action to the field on the screen (Again the field is constructed using S:Itertaor). Any help on this appreciated. Here is the code snippet.. String[] zipCode = new zipCode[10]; s:iterator value=zipCodeList var=Zcode status=rowstatus td align=center s:textfield required=true name=zipCode id=%{'zipCode[' + (#rowstatus.index) + ']'} value=%{Zcode} cssClass=textbox required=true size=5 theme=simple/ /td s:if test=((#rowstatus.index + 1) %6) == 0 /tr tr /s:if /s:iterator Thanks, JB -- View this message in context: http://www.nabble.com/Changing-the-border-color-of-a-text-field-tp25861145p25862090.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 - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Changing the border color of a text field
Alex, It is a great idea. But still I haven't got it working. value=%{fieldErrors['zipCode[ ' + #rowstatus.index + ']']}/ - always evaluates to null. Can you think of any reason why it could be so? On Mon, Oct 12, 2009 at 3:50 PM, Alex Siman aleksandr.si...@gmail.comwrote: Try to add next code: s:set var=zipCodeErrors value=%{fieldErrors['zipCode[' + #rowstatus.index + ']']}/ s:textfield ... cssStyle=%{(#zipCodeErrors != null #zipCodeErrors.size 0) ? 'border: 1px solid red;' : ''} ... / james billa wrote: Hi, I have a field called Preferred Zip codes : . The user is provided with 10 textfields for this to enter. He may enter 1 or more and submit the form. If any of the zip codes that he entered is not in my database, I need to change the border color of that textfield containing incorrect zip code alone to red and show the form back to user. How do I do this using Struts 2.1.6. I already know in my action class about the incorrect field. In JSP I have constructed text fields using s:iterator with value as dummy string array of size 10. Everything looks good. How to connect the error in action to the field on the screen (Again the field is constructed using S:Itertaor). Any help on this appreciated. Here is the code snippet.. String[] zipCode = new zipCode[10]; s:iterator value=zipCodeList var=Zcode status=rowstatus td align=center s:textfield required=true name=zipCode id=%{'zipCode[' + (#rowstatus.index) + ']'} value=%{Zcode} cssClass=textbox required=true size=5 theme=simple/ /td s:if test=((#rowstatus.index + 1) %6) == 0 /tr tr /s:if /s:iterator Thanks, JB -- View this message in context: http://www.nabble.com/Changing-the-border-color-of-a-text-field-tp25861145p25862090.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 value of tag attribute from OGNL?
Alex Siman wrote: Thanx you Dave for your advice! Sure, Alix. I switched off the JSTL-EL (as it was recomended in Struts2 wiki) Can you please point me to that? Seems quite strange to me... so I wrote another working code: snippets of java inside your .jsp seems like a step back about 8 years to me... P.S. What did you mean by this?: The answer is easier if this .tag file contains no recursive calls. If the location you're stashing the value in order to get to it from OGNL is not related to the call structure, then recursive calls will overwrite the values set by the parent. My example shoved the values into the request. Yours is putting them in the jspContext, but I believe that's also a shared jspContext for all the code that's generating that specific output. If you call myTagDir:myTag /, within it set a passed value in a larger scope, then make a recursive call also to myTagDir:myTag /, when that recursive call returns that larger scope will still contain the value passed into the the recursive call and *not* the value passed into the initial tag (and promoted to that larger scope location prior to the recursive call). -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: How to get value of tag attribute from OGNL?
on top of that, you can use the the struts set tag to set stuff in any of the contexts. Scriptlets are evil. musachy On Tue, Oct 13, 2009 at 9:41 AM, Dale Newfield d...@newfield.org wrote: Alex Siman wrote: Thanx you Dave for your advice! Sure, Alix. I switched off the JSTL-EL (as it was recomended in Struts2 wiki) Can you please point me to that? Seems quite strange to me... so I wrote another working code: snippets of java inside your .jsp seems like a step back about 8 years to me... P.S. What did you mean by this?: The answer is easier if this .tag file contains no recursive calls. If the location you're stashing the value in order to get to it from OGNL is not related to the call structure, then recursive calls will overwrite the values set by the parent. My example shoved the values into the request. Yours is putting them in the jspContext, but I believe that's also a shared jspContext for all the code that's generating that specific output. If you call myTagDir:myTag /, within it set a passed value in a larger scope, then make a recursive call also to myTagDir:myTag /, when that recursive call returns that larger scope will still contain the value passed into the the recursive call and *not* the value passed into the initial tag (and promoted to that larger scope location prior to the recursive call). -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- 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: How to get value of tag attribute from OGNL?
I switched off the JSTL-EL (as it was recomended in Struts2 wiki) Can you please point me to that? Seems quite strange to me... Read the section JSP 2.1 here: http://struts.apache.org/2.1.8/docs/ognl.html The answer is easier if this .tag file contains no recursive calls. I think this issues can be put back until .tag file calls itself, right? P.S. Dale, sorry for 'Dave')) Kinda 'Dale Newfield' ~= 'Dave Newton'. -- View this message in context: http://www.nabble.com/How-to-get-value-of-tag-attribute-from-OGNL--tp25862967p25877323.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 value of tag attribute from OGNL?
Why are scriptlets an evil? Is it relates to an architectural aspect that View (JSP) must contain no business logic? Or something else? BTW sometimes OGNL also contains little complex code. What about this one: s:set var=label value=%{#attr.labelKey != null ? getText(#attr.labelKey) : (#attr.label != null ? #attr.label : '')}/ It is not so kind to deal w/ code like that((. But what to do? Add one more function to *Action class? Musachy Barroso wrote: on top of that, you can use the the struts set tag to set stuff in any of the contexts. Scriptlets are evil. musachy On Tue, Oct 13, 2009 at 9:41 AM, Dale Newfield d...@newfield.org wrote: Alex Siman wrote: Thanx you Dave for your advice! Sure, Alix. I switched off the JSTL-EL (as it was recomended in Struts2 wiki) Can you please point me to that? Seems quite strange to me... so I wrote another working code: snippets of java inside your .jsp seems like a step back about 8 years to me... P.S. What did you mean by this?: The answer is easier if this .tag file contains no recursive calls. If the location you're stashing the value in order to get to it from OGNL is not related to the call structure, then recursive calls will overwrite the values set by the parent. My example shoved the values into the request. Yours is putting them in the jspContext, but I believe that's also a shared jspContext for all the code that's generating that specific output. If you call myTagDir:myTag /, within it set a passed value in a larger scope, then make a recursive call also to myTagDir:myTag /, when that recursive call returns that larger scope will still contain the value passed into the the recursive call and *not* the value passed into the initial tag (and promoted to that larger scope location prior to the recursive call). -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- 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 -- View this message in context: http://www.nabble.com/How-to-get-value-of-tag-attribute-from-OGNL--tp25862967p25877596.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: Changing the border color of a text field
I am confused about what getter are you using for String[] zipCode = new zipCode[10]; Is it 'getZipCode' or 'getZipCodeList'? If 'getZipCodeList' then try this one: s:iterator value=zipCodeList var=Zcode status=rowstatus ... s:set var=zipCodeErrors value=%{fieldErrors['zipCodeList[' + #rowstatus.index + ']']}/ ... /s:iterator james billa wrote: Alex, It is a great idea. But still I haven't got it working. value=%{fieldErrors['zipCode[ ' + #rowstatus.index + ']']}/ - always evaluates to null. Can you think of any reason why it could be so? On Mon, Oct 12, 2009 at 3:50 PM, Alex Siman aleksandr.si...@gmail.comwrote: Try to add next code: s:set var=zipCodeErrors value=%{fieldErrors['zipCode[' + #rowstatus.index + ']']}/ s:textfield ... cssStyle=%{(#zipCodeErrors != null #zipCodeErrors.size 0) ? 'border: 1px solid red;' : ''} ... / james billa wrote: Hi, I have a field called Preferred Zip codes : . The user is provided with 10 textfields for this to enter. He may enter 1 or more and submit the form. If any of the zip codes that he entered is not in my database, I need to change the border color of that textfield containing incorrect zip code alone to red and show the form back to user. How do I do this using Struts 2.1.6. I already know in my action class about the incorrect field. In JSP I have constructed text fields using s:iterator with value as dummy string array of size 10. Everything looks good. How to connect the error in action to the field on the screen (Again the field is constructed using S:Itertaor). Any help on this appreciated. Here is the code snippet.. String[] zipCode = new zipCode[10]; s:iterator value=zipCodeList var=Zcode status=rowstatus td align=center s:textfield required=true name=zipCode id=%{'zipCode[' + (#rowstatus.index) + ']'} value=%{Zcode} cssClass=textbox required=true size=5 theme=simple/ /td s:if test=((#rowstatus.index + 1) %6) == 0 /tr tr /s:if /s:iterator Thanks, JB -- View this message in context: http://www.nabble.com/Changing-the-border-color-of-a-text-field-tp25861145p25862090.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/Changing-the-border-color-of-a-text-field-tp25861145p25877861.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 value of tag attribute from OGNL?
trust me, that is nothing compared to what I have seen in scriptlets. That expression could be broken down into an if block, even the original is not that hard to read. Assuming you don't put any business logic in scriplets, which is evil by definition (an axiom I guess), pages containing scriptlets are very hard to read, maintain, and of course debug. Even reading your own scriptlets will be hard 6 months after you write them. Whenever you think you need an scriptlet, double check, there is a very high chance that you have other, cleaner, ways of doing the same thing. that's of course my very own personal opinion :) musachy On Tue, Oct 13, 2009 at 10:48 AM, Alex Siman aleksandr.si...@gmail.com wrote: Why are scriptlets an evil? Is it relates to an architectural aspect that View (JSP) must contain no business logic? Or something else? BTW sometimes OGNL also contains little complex code. What about this one: s:set var=label value=%{#attr.labelKey != null ? getText(#attr.labelKey) : (#attr.label != null ? #attr.label : '')}/ It is not so kind to deal w/ code like that((. But what to do? Add one more function to *Action class? Musachy Barroso wrote: on top of that, you can use the the struts set tag to set stuff in any of the contexts. Scriptlets are evil. musachy On Tue, Oct 13, 2009 at 9:41 AM, Dale Newfield d...@newfield.org wrote: Alex Siman wrote: Thanx you Dave for your advice! Sure, Alix. I switched off the JSTL-EL (as it was recomended in Struts2 wiki) Can you please point me to that? Seems quite strange to me... so I wrote another working code: snippets of java inside your .jsp seems like a step back about 8 years to me... P.S. What did you mean by this?: The answer is easier if this .tag file contains no recursive calls. If the location you're stashing the value in order to get to it from OGNL is not related to the call structure, then recursive calls will overwrite the values set by the parent. My example shoved the values into the request. Yours is putting them in the jspContext, but I believe that's also a shared jspContext for all the code that's generating that specific output. If you call myTagDir:myTag /, within it set a passed value in a larger scope, then make a recursive call also to myTagDir:myTag /, when that recursive call returns that larger scope will still contain the value passed into the the recursive call and *not* the value passed into the initial tag (and promoted to that larger scope location prior to the recursive call). -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- 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 -- View this message in context: http://www.nabble.com/How-to-get-value-of-tag-attribute-from-OGNL--tp25862967p25877596.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 -- 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: How to get value of tag attribute from OGNL?
Alex Siman wrote: I switched off the JSTL-EL (as it was recomended in Struts2 wiki) Can you please point me to that? Seems quite strange to me... Read the section JSP 2.1 here: http://struts.apache.org/2.1.8/docs/ognl.html That was added by Ted Husted on 3/23/2007. What are the problems that this addresses? It seems that the cure is worse than the disease of having to escape a few #'s here and there (none in my codebase), especially after we've since restricted all the struts tags with rtexprvalue=false... -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: How to get value of tag attribute from OGNL?
that's only a problem for defining maps in ognl, which used the #{a:b} syntax, which made the jstl el complain. The solution is just to use the alternative map syntax: #...@java.util.linkedhashmap@{ foo : foo value, bar : bar value } http://www.opensymphony.com/ognl/html/LanguageGuide/collectionConstruction.html#mapConstruction On Tue, Oct 13, 2009 at 12:27 PM, Dale Newfield d...@newfield.org wrote: Alex Siman wrote: I switched off the JSTL-EL (as it was recomended in Struts2 wiki) Can you please point me to that? Seems quite strange to me... Read the section JSP 2.1 here: http://struts.apache.org/2.1.8/docs/ognl.html That was added by Ted Husted on 3/23/2007. What are the problems that this addresses? It seems that the cure is worse than the disease of having to escape a few #'s here and there (none in my codebase), especially after we've since restricted all the struts tags with rtexprvalue=false... -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- 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: How to get value of tag attribute from OGNL?
Alex Siman wrote: I switched off the JSTL-EL (as it was recomended in Struts2 wiki) Can you please point me to that? Seems quite strange to me... Since we've removed the possibility of including JSTL-EL expressions in struts tag attributes, this advice is no longer appropriate. If that's the reason you chose to write huge scriptlets instead of small jstl tag calls, consider the advice rescinded. Read the section JSP 2.1 here: http://struts.apache.org/2.1.8/docs/ognl.html I have attempted to modify these to address this issue, but since the changes actually reside at http://cwiki.apache.org/confluence/display/WW/OGNL I'm not sure when/if those will propagate. The answer is easier if this .tag file contains no recursive calls. I think this issues can be put back until .tag file calls itself, right? Or until it calls another tag that also calls the original, correct. P.S. Dale, sorry for 'Dave')) Kinda 'Dale Newfield' ~= 'Dave Newton'. No big deal -- you're not the first to make that same mistake :-). I'm honored to be confused with someone whose advice I respect! On the other hand I should apologize right now for having in the past confused our two resident Martin's, who (IMHO) don't deserve equal respect! -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: How to get value of tag attribute from OGNL?
Cool, welcome back, JSTL-EL! DNewfield wrote: Alex Siman wrote: I switched off the JSTL-EL (as it was recomended in Struts2 wiki) Can you please point me to that? Seems quite strange to me... Since we've removed the possibility of including JSTL-EL expressions in struts tag attributes, this advice is no longer appropriate. If that's the reason you chose to write huge scriptlets instead of small jstl tag calls, consider the advice rescinded. Read the section JSP 2.1 here: http://struts.apache.org/2.1.8/docs/ognl.html I have attempted to modify these to address this issue, but since the changes actually reside at http://cwiki.apache.org/confluence/display/WW/OGNL I'm not sure when/if those will propagate. The answer is easier if this .tag file contains no recursive calls. I think this issues can be put back until .tag file calls itself, right? Or until it calls another tag that also calls the original, correct. P.S. Dale, sorry for 'Dave')) Kinda 'Dale Newfield' ~= 'Dave Newton'. No big deal -- you're not the first to make that same mistake :-). I'm honored to be confused with someone whose advice I respect! On the other hand I should apologize right now for having in the past confused our two resident Martin's, who (IMHO) don't deserve equal respect! -Dale - 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/How-to-get-value-of-tag-attribute-from-OGNL--tp25862967p25880814.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
Unit Testing in Struts 2.1.6
I have gone to the page found at http://struts.apache.org/2.1.6/docs/how-can-we-test-actions.html. However, the code on that page is not possible with Struts 2.1.6 although it is found in the docs for Struts 2.1.6. How can we get this page updated to show how to test actions in Struts 2.1.6 so I can have a better idea of how I would test my actions in my own apps?
iterator and radio struts2
Hi! I have the following class: public class Question implements Serializable { private Integer id; private String content; private String type; private ListAnswer answers = new ArrayListAnswer(); . } And class answer: public class Answer implements Serializable{ private Integer id; private String content; } I would like to iterate over the questions, and for each one display the option to choose the answer in a radio button. In the action class I have the followings: ListQuestion videoQuestion = ... (I get it from the database). List answers; I wrote the following code: s:iterate value=questions status=pos var=question s:property value=#question.content / s:radio name=answer[#pos.index] list=#question.answers listKey=id listValue=content / /s:iterate But I get an error message: Error on line 25, column 9 in template/simple/radiomap.ftl stack.findValue(parameters.listKey) is undefined. It cannot be assigned to itemKey The problematic instruction: -- == assignment: itemKey=stack.findValue(parameters.listKey) [on line 25, column 9 in template/simple/radiomap.ftl] in user-directive s.iterator [on line 23, column 1 in template/simple/radiomap.ftl] -- Java backtrace for programmers: -- freemarker.core.InvalidReferenceException: Error on line 25, column 9 in template/simple/radiomap.ftl stack.findValue(parameters.listKey) is undefined. It cannot be assigned to itemKey at freemarker.core.Assignment.accept(Assignment.java:111) at freemarker.core.Environment.visit(Environment.java:209) at freemarker.core.IfBlock.accept(IfBlock.java:82) why is it? I have getter and setter for id and content parameters of class Answer. As well, how can I retrieve the answers in the best way? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
RE: iterator and radio struts2
It looks like you may be able to nest s:iterator tags to achieve this. s:iterator value=%{questionsArrayFromActionClass} s:property value=%{theQuestion}/ s:iterator value=%{answersFromQuestionClass} s:radio... /s:iterator /s:iterator --Lee -Original Message- From: Odelya YomTov [mailto:ode...@jpost.com] Sent: Tuesday, October 13, 2009 6:09 PM To: 'Struts Users Mailing List' Subject: iterator and radio struts2 Hi! I have the following class: public class Question implements Serializable { private Integer id; private String content; private String type; private ListAnswer answers = new ArrayListAnswer(); . } And class answer: public class Answer implements Serializable{ private Integer id; private String content; } I would like to iterate over the questions, and for each one display the option to choose the answer in a radio button. /snip - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: iterator and radio struts2
hi! the problem was that i didn't have a get method for id and content. Now my question is: when i run the page, the source code writes the radio buttons like this: input type=radio name=answer[#pos.index] id=getFirstVideo_answer_#pos_index_5 value=5/ what i need it to save the answer for each question. how can i do it? what variable do i have to declare in the action class and how do i have to write the radiobutton value? On Wed, Oct 14, 2009 at 2:13 AM, Lee Clemens j...@leeclemens.net wrote: It looks like you may be able to nest s:iterator tags to achieve this. s:iterator value=%{questionsArrayFromActionClass} s:property value=%{theQuestion}/ s:iterator value=%{answersFromQuestionClass} s:radio... /s:iterator /s:iterator --Lee -Original Message- From: Odelya YomTov [mailto:ode...@jpost.com] Sent: Tuesday, October 13, 2009 6:09 PM To: 'Struts Users Mailing List' Subject: iterator and radio struts2 Hi! I have the following class: public class Question implements Serializable { private Integer id; private String content; private String type; private ListAnswer answers = new ArrayListAnswer(); . } And class answer: public class Answer implements Serializable{ private Integer id; private String content; } I would like to iterate over the questions, and for each one display the option to choose the answer in a radio button. /snip - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org -- what matters most is how you see yourself - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Portlet form action parameters doubles the namespace of actions
I noticed your bug report in JIRA and will be looking into it. As for debugging, check out the setup in the sample portlet application. I use it to run portlets embedded in pluto directly in Eclipse. Makes debugging real easy. Nils-H On Fri, Oct 9, 2009 at 10:35 AM, Leonard Broman leonard.bro...@gmail.com wrote: I reconfigured the project not to use the convention plugin and using the good old xml-configuration. But the problem persists. I'll try to dig into what might be causing this. Is anyone looking actively at the portlet plugin? Can anyone give me advice on development tools for debugging portlets? The portal I'm working in now i kind of heavy... 2009/10/8 Leonard Broman firepi...@gmail.com: Hi! I'm building a simple portlet using struts 2.1.8 with convention and the portlet plugin. I have an issue where is seems that the action url (submit url) has a doubled namespace like: Here's the query string: ?struts.portlet.mode=configdynamicAttributes=%7B%7Dsv.mode=configstruts.portlet.action=/email/config/email/config/configtemplateDir=templatetheme=simple From this I can see that it gets the /email/config/email/config namespace instead of just /email/config. Not unexpected, struts throws an exception about action not found when submit is clicked. This is only while running as a portlet, as webapp (test) everything works fine. Anyone has any clues? Leonard broman - 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