Re: if/elseif tag syntax
Hi Fabian, Can you give as the code of the Action that is in the Value Stack? Antonios On 27 June 2013 09:16, Fabian Richter frich...@mtg.de wrote: Hey, so I tried to use the s:if test= tag in one of my jsps and couldnt get neither working: s:if test=!empty certificate.statusisTrue/s:**if s:if test=certificate.status == 1isTrue/s:if s:if test=%{certificate.status == 1}isTrue/s:if s:if test=%{#certificate.status == 1}isTrue/s:if but ${certificate.status} outputs a 1. Using ${certificate.status} within test= throws a JSP exception that attribute test does not accept any expressions The only thing that works is: s:if test=%{true}isTrue/s:if What am I missing? TIA and best Fabian
Re: if/elseif tag syntax
Hi Antonios, you mean the java source Code or something I can extract from the jsp? The source code is confidential. I checked the get/set methods and getId on certificate returns a Long if thats what you wanted to know... Best Fabian Am 27.06.2013 10:24, schrieb Antonios Gkogkakis: Hi Fabian, Can you give as the code of the Action that is in the Value Stack? Antonios On 27 June 2013 09:16, Fabian Richter frich...@mtg.de wrote: Hey, so I tried to use the s:if test= tag in one of my jsps and couldnt get neither working: s:if test=!empty certificate.statusisTrue/s:**if s:if test=certificate.status == 1isTrue/s:if s:if test=%{certificate.status == 1}isTrue/s:if s:if test=%{#certificate.status == 1}isTrue/s:if but ${certificate.status} outputs a 1. Using ${certificate.status} within test= throws a JSP exception that attribute test does not accept any expressions The only thing that works is: s:if test=%{true}isTrue/s:if What am I missing? TIA and best Fabian -- media transfer AG Fabian Richter, M.Sc. Softwareentwickler Mail:frich...@mtg.de Telefon: +49 6151 8193-24 Telefax: +49 6151 8193-41 Web: http://www.mtg.de Firmensitz: Dolivostraße 11, 64293 Darmstadt Registergericht: Amtsgericht Darmstadt, HRB 8901 Vorstand: Jürgen Ruf (Vors.), Tamer Kemeröz Aufsichtsratsvorsitzender: Dr. Thomas Milde smime.p7s Description: S/MIME Kryptografische Unterschrift
Re: if/elseif tag syntax
Stupid me, getStatus was what I was reading and that one returns an int. Am 27.06.2013 10:33, schrieb Fabian Richter: Hi Antonios, you mean the java source Code or something I can extract from the jsp? The source code is confidential. I checked the get/set methods and getId on certificate returns a Long if thats what you wanted to know... Best Fabian Am 27.06.2013 10:24, schrieb Antonios Gkogkakis: Hi Fabian, Can you give as the code of the Action that is in the Value Stack? Antonios On 27 June 2013 09:16, Fabian Richter frich...@mtg.de wrote: Hey, so I tried to use the s:if test= tag in one of my jsps and couldnt get neither working: s:if test=!empty certificate.statusisTrue/s:**if s:if test=certificate.status == 1isTrue/s:if s:if test=%{certificate.status == 1}isTrue/s:if s:if test=%{#certificate.status == 1}isTrue/s:if but ${certificate.status} outputs a 1. Using ${certificate.status} within test= throws a JSP exception that attribute test does not accept any expressions The only thing that works is: s:if test=%{true}isTrue/s:if What am I missing? TIA and best Fabian -- media transfer AG Fabian Richter, M.Sc. Softwareentwickler Mail:frich...@mtg.de Telefon: +49 6151 8193-24 Telefax: +49 6151 8193-41 Web: http://www.mtg.de Firmensitz: Dolivostraße 11, 64293 Darmstadt Registergericht: Amtsgericht Darmstadt, HRB 8901 Vorstand: Jürgen Ruf (Vors.), Tamer Kemeröz Aufsichtsratsvorsitzender: Dr. Thomas Milde smime.p7s Description: S/MIME Kryptografische Unterschrift
Re: if/elseif tag syntax
Long would be fine as well, I tested option 2 and 3 and it works, the important thing is to have gettersfor certificate and status. and an object that has a certificate field in your value stack, Your last option is probably not valid unless you have used s:set to push a bean in the value stack with name certificate (not 100% sure though) On 27 June 2013 09:42, Fabian Richter frich...@mtg.de wrote: Stupid me, getStatus was what I was reading and that one returns an int. Am 27.06.2013 10:33, schrieb Fabian Richter: Hi Antonios, you mean the java source Code or something I can extract from the jsp? The source code is confidential. I checked the get/set methods and getId on certificate returns a Long if thats what you wanted to know... Best Fabian Am 27.06.2013 10:24, schrieb Antonios Gkogkakis: Hi Fabian, Can you give as the code of the Action that is in the Value Stack? Antonios On 27 June 2013 09:16, Fabian Richter frich...@mtg.de wrote: Hey, so I tried to use the s:if test= tag in one of my jsps and couldnt get neither working: s:if test=!empty certificate.statusisTrue/s:if s:if test=certificate.status == 1isTrue/s:if s:if test=%{certificate.status == 1}isTrue/s:if s:if test=%{#certificate.status == 1}isTrue/s:if but ${certificate.status} outputs a 1. Using ${certificate.status} within test= throws a JSP exception that attribute test does not accept any expressions The only thing that works is: s:if test=%{true}isTrue/s:if What am I missing? TIA and best Fabian -- media transfer AG Fabian Richter, M.Sc. Softwareentwickler Mail:frich...@mtg.de Telefon: +49 6151 8193-24 Telefax: +49 6151 8193-41 Web: http://www.mtg.de Firmensitz: Dolivostraße 11, 64293 Darmstadt Registergericht: Amtsgericht Darmstadt, HRB 8901 Vorstand: Jürgen Ruf (Vors.), Tamer Kemeröz Aufsichtsratsvorsitzender: Dr. Thomas Milde
Re: if/elseif tag syntax
All objects have getters/setters set, this is the except of the jsp code with the problem (trying to write a text that depends on the value of certificate.status into a table cell): td class=cell valign=top s:if test=%{certificate.status==1} fmt:message key=certificate.status.valid / /s:if s:elseif test=%{certificate.status==2} fmt:message key=certificate.status.revoked / /s:elseif s:elseif test=%{certificate.status==4} fmt:message key=certificate.status.onhold / /s:elseif s:elseif test=%{certificate.status==5} fmt:message key=certificate.status.expired / /s:elseif s:else ${certificate.status} /s:else /td The result is that in every of these table cells only the integer value is written, hence the else branch is executed. Any idea why? Best Fabian Am 27.06.2013 10:50, schrieb Antonios Gkogkakis: Long would be fine as well, I tested option 2 and 3 and it works, the important thing is to have gettersfor certificate and status. and an object that has a certificate field in your value stack, Your last option is probably not valid unless you have used s:set to push a bean in the value stack with name certificate (not 100% sure though) On 27 June 2013 09:42, Fabian Richter frich...@mtg.de wrote: Stupid me, getStatus was what I was reading and that one returns an int. Am 27.06.2013 10:33, schrieb Fabian Richter: Hi Antonios, you mean the java source Code or something I can extract from the jsp? The source code is confidential. I checked the get/set methods and getId on certificate returns a Long if thats what you wanted to know... Best Fabian Am 27.06.2013 10:24, schrieb Antonios Gkogkakis: Hi Fabian, Can you give as the code of the Action that is in the Value Stack? Antonios On 27 June 2013 09:16, Fabian Richter frich...@mtg.de wrote: Hey, so I tried to use the s:if test= tag in one of my jsps and couldnt get neither working: s:if test=!empty certificate.statusisTrue/s:if s:if test=certificate.status == 1isTrue/s:if s:if test=%{certificate.status == 1}isTrue/s:if s:if test=%{#certificate.status == 1}isTrue/s:if but ${certificate.status} outputs a 1. Using ${certificate.status} within test= throws a JSP exception that attribute test does not accept any expressions The only thing that works is: s:if test=%{true}isTrue/s:if What am I missing? TIA and best Fabian -- media transfer AG Fabian Richter, M.Sc. Softwareentwickler Mail:frich...@mtg.de Telefon: +49 6151 8193-24 Telefax: +49 6151 8193-41 Web: http://www.mtg.de Firmensitz: Dolivostraße 11, 64293 Darmstadt Registergericht: Amtsgericht Darmstadt, HRB 8901 Vorstand: Jürgen Ruf (Vors.), Tamer Kemeröz Aufsichtsratsvorsitzender: Dr. Thomas Milde -- media transfer AG Fabian Richter, M.Sc. Softwareentwickler Mail:frich...@mtg.de Telefon: +49 6151 8193-24 Telefax: +49 6151 8193-41 Web: http://www.mtg.de Firmensitz: Dolivostraße 11, 64293 Darmstadt Registergericht: Amtsgericht Darmstadt, HRB 8901 Vorstand: Jürgen Ruf (Vors.), Tamer Kemeröz Aufsichtsratsvorsitzender: Dr. Thomas Milde smime.p7s Description: S/MIME Kryptografische Unterschrift
Re: if/elseif tag syntax
I would temporarily remove ${certificate.status} from the else and I would check if the getStatus is called for the conditionals Antonios On 27 June 2013 09:56, Fabian Richter frich...@mtg.de wrote: All objects have getters/setters set, this is the except of the jsp code with the problem (trying to write a text that depends on the value of certificate.status into a table cell): td class=cell valign=top s:if test=%{certificate.status==1}** fmt:message key=certificate.status.valid / /s:if s:elseif test=%{certificate.status==2}** fmt:message key=certificate.status.**revoked / /s:elseif s:elseif test=%{certificate.status==4}** fmt:message key=certificate.status.**onhold / /s:elseif s:elseif test=%{certificate.status==5}** fmt:message key=certificate.status.**expired / /s:elseif s:else ${certificate.status} /s:else /td The result is that in every of these table cells only the integer value is written, hence the else branch is executed. Any idea why? Best Fabian Am 27.06.2013 10:50, schrieb Antonios Gkogkakis: Long would be fine as well, I tested option 2 and 3 and it works, the important thing is to have gettersfor certificate and status. and an object that has a certificate field in your value stack, Your last option is probably not valid unless you have used s:set to push a bean in the value stack with name certificate (not 100% sure though) On 27 June 2013 09:42, Fabian Richter frich...@mtg.de wrote: Stupid me, getStatus was what I was reading and that one returns an int. Am 27.06.2013 10:33, schrieb Fabian Richter: Hi Antonios, you mean the java source Code or something I can extract from the jsp? The source code is confidential. I checked the get/set methods and getId on certificate returns a Long if thats what you wanted to know... Best Fabian Am 27.06.2013 10:24, schrieb Antonios Gkogkakis: Hi Fabian, Can you give as the code of the Action that is in the Value Stack? Antonios On 27 June 2013 09:16, Fabian Richter frich...@mtg.de wrote: Hey, so I tried to use the s:if test= tag in one of my jsps and couldnt get neither working: s:if test=!empty certificate.statusisTrue/s:**if s:if test=certificate.status == 1isTrue/s:if s:if test=%{certificate.status == 1}isTrue/s:if s:if test=%{#certificate.status == 1}isTrue/s:if but ${certificate.status} outputs a 1. Using ${certificate.status} within test= throws a JSP exception that attribute test does not accept any expressions The only thing that works is: s:if test=%{true}isTrue/s:if What am I missing? TIA and best Fabian -- media transfer AG Fabian Richter, M.Sc. Softwareentwickler Mail:frich...@mtg.de Telefon: +49 6151 8193-24 Telefax: +49 6151 8193-41 Web: http://www.mtg.de Firmensitz: Dolivostraße 11, 64293 Darmstadt Registergericht: Amtsgericht Darmstadt, HRB 8901 Vorstand: Jürgen Ruf (Vors.), Tamer Kemeröz Aufsichtsratsvorsitzender: Dr. Thomas Milde -- media transfer AG Fabian Richter, M.Sc. Softwareentwickler Mail:frich...@mtg.de Telefon: +49 6151 8193-24 Telefax: +49 6151 8193-41 Web: http://www.mtg.de Firmensitz: Dolivostraße 11, 64293 Darmstadt Registergericht: Amtsgericht Darmstadt, HRB 8901 Vorstand: Jürgen Ruf (Vors.), Tamer Kemeröz Aufsichtsratsvorsitzender: Dr. Thomas Milde
Re: if/elseif tag syntax
Am 27.06.2013 11:20, schrieb Antonios Gkogkakis: I would temporarily remove ${certificate.status} from the else and I would check if the getStatus is called for the conditionals Yes, it is called. I was hoping it wasn't :( What now? smime.p7s Description: S/MIME Kryptografische Unterschrift
Re: if/elseif tag syntax
if it's called then there is something wrong with the comparison, are you sure that you don't have a String getStatus somewhere? What I would do is instead of checking the == 1 in the jsp create a method on the certificate boolean isValid() { return status==1} and so on. I know it doesn't answer your original question but it solves the problem and it's more maintenable IMHO. Antonios On 27 June 2013 10:34, Fabian Richter frich...@mtg.de wrote: Am 27.06.2013 11:20, schrieb Antonios Gkogkakis: I would temporarily remove ${certificate.status} from the else and I would check if the getStatus is called for the conditionals Yes, it is called. I was hoping it wasn't :( What now?
Re: if/elseif tag syntax
I have an update: I enabled the ${certificate.status} in the else branch again and checked the tomcat logs: getStatus called: 0 getStatus called: 0 getStatus called: 0 getStatus called: 0 getStatus called: 1 That would mean that for each if/elseif he doesnt actually call getStatus on the actual certificate, but on a fake (?) one he created on the fly? I think I remember reading something in the Webworks book, that if there is no object he creates it on the fly and then all field are uninitialized which is a 0 for int? Or is that nonsense? And if it might be true, why does he correctly read the object via ${certificate.status} but not in the test=... ? Am 27.06.2013 12:26, schrieb Antonios Gkogkakis: if it's called then there is something wrong with the comparison, are you sure that you don't have a String getStatus somewhere? What I would do is instead of checking the == 1 in the jsp create a method on the certificate boolean isValid() { return status==1} and so on. I know it doesn't answer your original question but it solves the problem and it's more maintenable IMHO. Antonios On 27 June 2013 10:34, Fabian Richter frich...@mtg.de wrote: Am 27.06.2013 11:20, schrieb Antonios Gkogkakis: I would temporarily remove ${certificate.status} from the else and I would check if the getStatus is called for the conditionals Yes, it is called. I was hoping it wasn't :( What now? -- media transfer AG Fabian Richter, M.Sc. Softwareentwickler Mail:frich...@mtg.de Telefon: +49 6151 8193-24 Telefax: +49 6151 8193-41 Web: http://www.mtg.de Firmensitz: Dolivostraße 11, 64293 Darmstadt Registergericht: Amtsgericht Darmstadt, HRB 8901 Vorstand: Jürgen Ruf (Vors.), Tamer Kemeröz Aufsichtsratsvorsitzender: Dr. Thomas Milde smime.p7s Description: S/MIME Kryptografische Unterschrift
Re: if/elseif tag syntax
I assume you are on Struts2. I'm not familiar with the ${} expression, but you are right, there is an OGNL null handler that will instantiate objects for you if they are null, so the behaviour we see makes sense, which means that you don't have a certificate in the value stack. How do you access your view ? Prior to getting your view, you should have an action that gets executed in an Action class which has a certificate field, which gets populated prior to returning to the view. Antonios On 27 June 2013 11:33, Fabian Richter frich...@mtg.de wrote: I have an update: I enabled the ${certificate.status} in the else branch again and checked the tomcat logs: getStatus called: 0 getStatus called: 0 getStatus called: 0 getStatus called: 0 getStatus called: 1 That would mean that for each if/elseif he doesnt actually call getStatus on the actual certificate, but on a fake (?) one he created on the fly? I think I remember reading something in the Webworks book, that if there is no object he creates it on the fly and then all field are uninitialized which is a 0 for int? Or is that nonsense? And if it might be true, why does he correctly read the object via ${certificate.status} but not in the test=... ? Am 27.06.2013 12:26, schrieb Antonios Gkogkakis: if it's called then there is something wrong with the comparison, are you sure that you don't have a String getStatus somewhere? What I would do is instead of checking the == 1 in the jsp create a method on the certificate boolean isValid() { return status==1} and so on. I know it doesn't answer your original question but it solves the problem and it's more maintenable IMHO. Antonios On 27 June 2013 10:34, Fabian Richter frich...@mtg.de wrote: Am 27.06.2013 11:20, schrieb Antonios Gkogkakis: I would temporarily remove ${certificate.status} from the else and I would check if the getStatus is called for the conditionals Yes, it is called. I was hoping it wasn't :( What now? -- media transfer AG Fabian Richter, M.Sc. Softwareentwickler Mail:frich...@mtg.de Telefon: +49 6151 8193-24 Telefax: +49 6151 8193-41 Web: http://www.mtg.de Firmensitz: Dolivostraße 11, 64293 Darmstadt Registergericht: Amtsgericht Darmstadt, HRB 8901 Vorstand: Jürgen Ruf (Vors.), Tamer Kemeröz Aufsichtsratsvorsitzender: Dr. Thomas Milde
Re: if/elseif tag syntax
Am 27.06.2013 12:43, schrieb Antonios Gkogkakis: I assume you are on Struts2. Yes, I am, more precisely I am migrating an application from Webwork to Struts2. I'm not familiar with the ${} expression, but you are right, there is an OGNL null handler that will instantiate objects for you if they are null, so the behaviour we see makes sense, which means that you don't have a certificate in the value stack. How do you access your view ? Prior to getting your view, you should have an action that gets executed in an Action class which has a certificate field, which gets populated prior to returning to the view. I definitely have an Action class with a certificate field, the action also gets called within that Action class, but how do I populate the certificate field? I thought that was done automatically as it is a field of the Action class. Best Fabian smime.p7s Description: S/MIME Kryptografische Unterschrift
Re: if/elseif tag syntax
But how would the framework know with what to populate it? You either do it manually in the body of the action that you execute to reach the view ,e.g., certificate = //logic to get the certificate or you can implement the ModelDriven interface which has a method (prepare I think) that gets called prior to executing the action Antonios On 27 June 2013 11:49, Fabian Richter frich...@mtg.de wrote: Am 27.06.2013 12:43, schrieb Antonios Gkogkakis: I assume you are on Struts2. Yes, I am, more precisely I am migrating an application from Webwork to Struts2. I'm not familiar with the ${} expression, but you are right, there is an OGNL null handler that will instantiate objects for you if they are null, so the behaviour we see makes sense, which means that you don't have a certificate in the value stack. How do you access your view ? Prior to getting your view, you should have an action that gets executed in an Action class which has a certificate field, which gets populated prior to returning to the view. I definitely have an Action class with a certificate field, the action also gets called within that Action class, but how do I populate the certificate field? I thought that was done automatically as it is a field of the Action class. Best Fabian
Re: if/elseif tag syntax
Am 27.06.2013 12:59, schrieb Antonios Gkogkakis: But how would the framework know with what to populate it? You either do it manually in the body of the action that you execute to reach the view ,e.g., certificate = //logic to get the certificate or you can implement the ModelDriven interface which has a method (prepare I think) that gets called prior to executing the action Thank you for that information, another gap closed :) I tested something that had similar results but wasnt sure if I understood what was happening correctly. So I checked the jsp code further, and certificate is defined in the surrounding forEach c:forEach var=certificate items=${request.localCertificates} Which is a JSTL Core tag, how can I access these vars from struts tags? Or is nesting struts and JSTL tags a very bad idea? I thought that forEach line was pushing the certificate onto the ValueStack but then I would be able to read it via certificate anywhere within the forEach enclosing lines right? Best smime.p7s Description: S/MIME Kryptografische Unterschrift
RE: if/elseif tag syntax
Date: Thu, 27 Jun 2013 13:21:35 +0200 From: frich...@mtg.de To: user@struts.apache.org Subject: Re: if/elseif tag syntax Am 27.06.2013 12:59, schrieb Antonios Gkogkakis: But how would the framework know with what to populate it? You either do it manually in the body of the action that you execute to reach the view ,e.g., certificate = //logic to get the certificate or you can implement the ModelDriven interface which has a method (prepare I think) that gets called prior to executing the action Thank you for that information, another gap closed :) I tested something that had similar results but wasnt sure if I understood what was happening correctly. So I checked the jsp code further, and certificate is defined in the surrounding forEach c:forEach var=certificate items=${request.localCertificates} Which is a JSTL Core tag, how can I access these vars from struts tags? c:forEach items=${request.localCertificates} var=name tr tdc:out value=${certificate}//td tdc:out value=${certificate[wrappedCert[issuerX500Principal[ [RFC2253] ] ] ]}//td /tr /c:forEachMG Or is nesting struts and JSTL tags a very bad idea? MGnot if you reference by unique taglib declaratorsors e.g.%@ taglib uri=http://java.sun.com/jstl/core; prefix=c % %@ taglib prefix=s uri=/struts-tags % I thought that forEach line was pushing the certificate onto the ValueStack but then I would be able to read it via certificate anywhere within the forEach enclosing lines right? MGValueStack is a Collection class only for struts collection classes MGValueStack is accessed with OGNL (object graph notational language) when parser sees the # prefix e.g. s:property value=#name/ http://www.tutorialspoint.com/struts_2/struts_value_stack_ognl.htm Best MG*Gruss* MGMartin