You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by briano <br...@gmail.com> on 2012/07/19 00:44:24 UTC

beandisplay hide label if value is null?

Is there an way with the beandisplay component to have it not show the labels
(and values) if the value is null or empty? 

For example: 

Label1 -- Value1
Label2 -- Null
Label3 -- Value3

Would display as: 

Label1 -- Value1
Label3 -- Value3

If not then is there another way to dynamically do this without having to
check every single field for nulls?

<t:if test="object.value1">
  // display it
</t:if>

--
View this message in context: http://tapestry.1045711.n5.nabble.com/beandisplay-hide-label-if-value-is-null-tp5714585.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: beandisplay hide label if value is null?

Posted by briano <br...@gmail.com>.
That worked. Thank you very much.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/beandisplay-hide-label-if-value-is-null-tp5714585p5714605.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: beandisplay hide label if value is null?

Posted by Lance Java <la...@googlemail.com>.
You could use the exclude parameter

<t:beandisplay object="user" exclude="prop:excludes" />

public String getExcludes() {
   // return a comma separated list of property names based on some logic or
null
}

--
View this message in context: http://tapestry.1045711.n5.nabble.com/beandisplay-hide-label-if-value-is-null-tp5714585p5714592.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: beandisplay hide label if value is null?

Posted by Pavel Vodenski <pa...@beckon.com>.
Write a wrapper component around BeanDisplay and name it something like
BeanOptionalDisplay. That way, you only write the 'if (obj != null)' bit
one time.

- P

On Wed, Oct 31, 2012 at 10:39 AM, arterzatij <ar...@gmail.com> wrote:

> And how to avoid NPE on beandisplay if the obj is null?
>
> I dont want to test the null value every time that I need to verify the
> obj,
> on my app there are data that is not required so I want to display
> something
> like "Data no available" like grid does when there is no rows...
>
> Suggestions?
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/beandisplay-hide-label-if-value-is-null-tp5714585p5717465.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: beandisplay hide label if value is null?

Posted by arterzatij <ar...@gmail.com>.
And how to avoid NPE on beandisplay if the obj is null?

I dont want to test the null value every time that I need to verify the obj,
on my app there are data that is not required so I want to display something
like "Data no available" like grid does when there is no rows...

Suggestions?



--
View this message in context: http://tapestry.1045711.n5.nabble.com/beandisplay-hide-label-if-value-is-null-tp5714585p5717465.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: beandisplay hide label if value is null?

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 18 Jul 2012 19:44:24 -0300, briano <br...@gmail.com> wrote:

> Is there an way with the beandisplay component to have it not show the  
> labels (and values) if the value is null or empty?

Use the BeanModelSource to get a BeanModel, change it, then pass it to  
BeanDisplay.

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org