|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
S2: how to deal with NULL value with s:text tag?The following entry works fine, but when "xaction.contractPrice" is
NULL it prints out "null" on my web page. <s:text name="format.money"><s:param value="#xaction.contractPrice"/></s:text> This sort of fixes the issue, but I would prefer to not display a "$0". <s:text name="format.money"><s:param value="%{#xaction.contractPrice==null ? 0 : #xaction.contractPrice}"/></s:text> This does not work as I get an error: "cannot forward object as a number" <s:text name="format.money"><s:param value="%{#xaction.contractPrice==null ? ' ' : #xaction.contractPrice}"/></s:text> Properties file entry: format.money = {0,number,\u00A4###,##0} Is there something simple I am missing or a better way to do this? Is there a "$!" like freemarker or a "default value" parameter? --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: S2: how to deal with NULL value with s:text tag?Hi,
I have had same problems when displaying dates. The only solution I found was quite similar but maybe a little more flexible since you can choose to display nothing: <s:property value="#item.referenceDate != null ? getText('format.date',{#item.referenceDate}) : ' '" escape="false"/> Samuel 2009/11/7 Burton Rhodes <burtonrhodes@...> > The following entry works fine, but when "xaction.contractPrice" is > NULL it prints out "null" on my web page. > <s:text name="format.money"><s:param > value="#xaction.contractPrice"/></s:text> > > This sort of fixes the issue, but I would prefer to not display a "$0". > <s:text name="format.money"><s:param > value="%{#xaction.contractPrice==null ? 0 : > #xaction.contractPrice}"/></s:text> > This does not work as I get an error: "cannot forward object as a number" > <s:text name="format.money"><s:param > value="%{#xaction.contractPrice==null ? ' ' : > #xaction.contractPrice}"/></s:text> > > Properties file entry: > format.money = {0,number,\u00A4###,##0} > > Is there something simple I am missing or a better way to do this? Is > there a "$!" like freemarker or a "default value" parameter? > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > |
|
|
Re: S2: how to deal with NULL value with s:text tag?Thanks for the reply. There should definately be some sort of
enhancment to the <s:text> tag. I found a more susinct solution with the <fmt:formatNumber> tag - it doesn't display the "null" text if the value is null. Anyone know if there is a request to add a "null" feature to <s:text>? The <s:date> tag handles "null" without displaying "null" text. Wonder why <s:text> is different? I can't think of many situations where the UI calls for displaying "null" when a value being displayed is in fact null. <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <fmt:formatNumber value="${xaction.listPrice}" type="currency" maxFractionDigits="0"/> <s:date name="#xaction.closingDate" format="MMM dd, yyyy" /> On Sat, Nov 7, 2009 at 4:02 PM, Samuel Robert <samuelrobert.job@...> wrote: > Hi, > > I have had same problems when displaying dates. > The only solution I found was quite similar but maybe a little more flexible > since you can choose to display nothing: > <s:property value="#item.referenceDate != null ? > getText('format.date',{#item.referenceDate}) : ' '" escape="false"/> > > Samuel > > 2009/11/7 Burton Rhodes <burtonrhodes@...> > >> The following entry works fine, but when "xaction.contractPrice" is >> NULL it prints out "null" on my web page. >> <s:text name="format.money"><s:param >> value="#xaction.contractPrice"/></s:text> >> >> This sort of fixes the issue, but I would prefer to not display a "$0". >> <s:text name="format.money"><s:param >> value="%{#xaction.contractPrice==null ? 0 : >> #xaction.contractPrice}"/></s:text> >> This does not work as I get an error: "cannot forward object as a number" >> <s:text name="format.money"><s:param >> value="%{#xaction.contractPrice==null ? ' ' : >> #xaction.contractPrice}"/></s:text> >> >> Properties file entry: >> format.money = {0,number,\u00A4###,##0} >> >> Is there something simple I am missing or a better way to do this? Is >> there a "$!" like freemarker or a "default value" parameter? >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@... >> For additional commands, e-mail: user-help@... >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: S2: how to deal with NULL value with s:text tag?Burton Rhodes wrote:
> Thanks for the reply. There should definately be some sort of > enhancment to the <s:text> tag. I found a more susinct solution with > the <fmt:formatNumber> tag - it doesn't display the "null" text if the > value is null. If JSTL functionality is the same as the S2 tag then the JSTL tag should be preferred anyway. Dave --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: S2: how to deal with NULL value with s:text tag?that should be fixed, could you please open a jira ticket with the details?
http://issues.apache.org/struts/browse/WW musachy On Sun, Nov 8, 2009 at 8:31 AM, Burton Rhodes <burtonrhodes@...> wrote: > Thanks for the reply. There should definately be some sort of > enhancment to the <s:text> tag. I found a more susinct solution with > the <fmt:formatNumber> tag - it doesn't display the "null" text if the > value is null. Anyone know if there is a request to add a "null" > feature to <s:text>? The <s:date> tag handles "null" without > displaying "null" text. Wonder why <s:text> is different? I can't > think of many situations where the UI calls for displaying "null" when > a value being displayed is in fact null. > > <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> > <fmt:formatNumber value="${xaction.listPrice}" type="currency" > maxFractionDigits="0"/> > > <s:date name="#xaction.closingDate" format="MMM dd, yyyy" /> > > > On Sat, Nov 7, 2009 at 4:02 PM, Samuel Robert > <samuelrobert.job@...> wrote: >> Hi, >> >> I have had same problems when displaying dates. >> The only solution I found was quite similar but maybe a little more flexible >> since you can choose to display nothing: >> <s:property value="#item.referenceDate != null ? >> getText('format.date',{#item.referenceDate}) : ' '" escape="false"/> >> >> Samuel >> >> 2009/11/7 Burton Rhodes <burtonrhodes@...> >> >>> The following entry works fine, but when "xaction.contractPrice" is >>> NULL it prints out "null" on my web page. >>> <s:text name="format.money"><s:param >>> value="#xaction.contractPrice"/></s:text> >>> >>> This sort of fixes the issue, but I would prefer to not display a "$0". >>> <s:text name="format.money"><s:param >>> value="%{#xaction.contractPrice==null ? 0 : >>> #xaction.contractPrice}"/></s:text> >>> This does not work as I get an error: "cannot forward object as a number" >>> <s:text name="format.money"><s:param >>> value="%{#xaction.contractPrice==null ? ' ' : >>> #xaction.contractPrice}"/></s:text> >>> >>> Properties file entry: >>> format.money = {0,number,\u00A4###,##0} >>> >>> Is there something simple I am missing or a better way to do this? Is >>> there a "$!" like freemarker or a "default value" parameter? >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: user-unsubscribe@... >>> For additional commands, e-mail: user-help@... >>> >>> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
| Free embeddable forum powered by Nabble | Forum Help |