Re: s:if test condition
OMG! that was it!!! I would never have figured out by myself, THANKS BILL!!! 2010/6/26 Bill Bohnenberger bill98...@gmail.com Since 'activated' is a String, try swapping your single double quotes, e.g. s:if test='%{warning.activated==Y}' -Bill On Sat, Jun 26, 2010 at 11:28 AM, lucas owen sr.ilus...@gmail.com wrote: Hi Struts 2 users: I was wondering if you can use a s:if test based on a pojo's attribute value: POJO: public class Warning{ String text; String activated; // Y or N } JSP: s:if test=*%{warning==null}* -- *Warning* null! /s:if s:else -- *Warning* not null! -- Activated: s:property value=*warning.activated*/ s:if test=*warning.activated == 'Y' * -- *Warning* *activated*. /s:if s:else -- *Warning* *deactivated*. /s:else /s:else The first test (check null value) works OK, but the second always goes through the else part. I have tried test=*%{warning.activated == 'Y' } and *test=*%{#warning.activated == 'Y' } *too but it doesnt work either. I dont know what is wrong, s:property value=*warning.activated*/ shows the value correctly... I know I can use an auxiliar boolean variable depending on the value Y/N but I would like to know why it doesnt work this way. THANKS IN ADVANCE
Re: s:if test condition
lucas owen wrote: Bill Bohnenbergerbill98...@gmail.com Since 'activated' is a String, try swapping your single double quotes, e.g. s:if test='%{warning.activated==Y}' that was it!!! The key is understanding *why* it makes a difference. The reason is that a single character demarcated by single quotes is not a String, it is a character. The character 'Y' is not equal to the String Y. http://struts.apache.org/2.1.8.1/docs/why-wont-the-if-tag-evaluate-a-one-char-string.html -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: s:if test condition
Yes, that is why I said Since 'activated' is a String,... On Sun, Jun 27, 2010 at 3:47 PM, Dale Newfield d...@newfield.org wrote: lucas owen wrote: Bill Bohnenbergerbill98...@gmail.com Since 'activated' is a String, try swapping your single double quotes, e.g. s:if test='%{warning.activated==Y}' that was it!!! The key is understanding *why* it makes a difference. The reason is that a single character demarcated by single quotes is not a String, it is a character. The character 'Y' is not equal to the String Y. http://struts.apache.org/2.1.8.1/docs/why-wont-the-if-tag-evaluate-a-one-char-string.html -Dale - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
s:if test condition
Hi Struts 2 users: I was wondering if you can use a s:if test based on a pojo's attribute value: POJO: public class Warning{ String text; String activated; // Y or N } JSP: s:if test=*%{warning==null}* -- *Warning* null! /s:if s:else -- *Warning* not null! -- Activated: s:property value=*warning.activated*/ s:if test=*warning.activated == 'Y' * -- *Warning* *activated*. /s:if s:else -- *Warning* *deactivated*. /s:else /s:else The first test (check null value) works OK, but the second always goes through the else part. I have tried test=*%{warning.activated == 'Y' } and *test=*%{#warning.activated == 'Y' } *too but it doesnt work either. I dont know what is wrong, s:property value=*warning.activated*/ shows the value correctly... I know I can use an auxiliar boolean variable depending on the value Y/N but I would like to know why it doesnt work this way. THANKS IN ADVANCE
Re: s:if test condition
Since 'activated' is a String, try swapping your single double quotes, e.g. s:if test='%{warning.activated==Y}' -Bill On Sat, Jun 26, 2010 at 11:28 AM, lucas owen sr.ilus...@gmail.com wrote: Hi Struts 2 users: I was wondering if you can use a s:if test based on a pojo's attribute value: POJO: public class Warning{ String text; String activated; // Y or N } JSP: s:if test=*%{warning==null}* -- *Warning* null! /s:if s:else -- *Warning* not null! -- Activated: s:property value=*warning.activated*/ s:if test=*warning.activated == 'Y' * -- *Warning* *activated*. /s:if s:else -- *Warning* *deactivated*. /s:else /s:else The first test (check null value) works OK, but the second always goes through the else part. I have tried test=*%{warning.activated == 'Y' } and *test=*%{#warning.activated == 'Y' } *too but it doesnt work either. I dont know what is wrong, s:property value=*warning.activated*/ shows the value correctly... I know I can use an auxiliar boolean variable depending on the value Y/N but I would like to know why it doesnt work this way. THANKS IN ADVANCE