You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ken in Nashua <kc...@live.com> on 2012/10/01 06:55:52 UTC

Label component usage

Folks,

I am using the Label component to model some space maintainers in between the postions of components. kinda like filling up empty table columns ?

<td colspan="0">
    <div style="font-weight:bold; text-align: center;">
        <t:Label for=""/>        
        
        <t:outputRaw value="${cursor} + 1"/>
        
        <t:Label for=""> to </t:Label>
        
        <t:if test="cursor">    
            <t:outputRaw value="${cursor} + min(collection.size,itemsPerPage) "/>
            <p:else>
                <t:outputRaw value="${cursor} + min(collection.size,itemsPerPage) "/>
            </p:else>                            
        </t:if>        
        
        <t:Label for=""> of </t:Label>
        <t:Label for="">collection.size</t:Label>
        <t:Label for=""/>
    </div>
</td>

But the Label component is being annoying. Why do I have to anchor it to an id with the for parameter. Is there some animation I am unexpectedly getting that it wants to do under the hood ?

All I want to do is animate some empty NOP label spots and use a few labels to render some text.

What do i do in the case where I dont have an ID?

Thanks in advance... 

kcolassi@live.com
 

 		 	   		  

Re: Label component usage

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 01 Oct 2012 01:55:52 -0300, Ken in Nashua <kc...@live.com>  
wrote:

> Folks,
>

Hi!

> I am using the Label component to model some space maintainers in  
> between the postions of components. kinda like filling up empty table  
> columns ?

You're using the Label component for the wrong purpose. The correct one is  
to provide <label> elements for form field components. That's why the  
'for' parameter is required.

> All I want to do is animate some empty NOP label spots and use a few  
> labels to render some text.

Just use the <label> HTML directly, without using the Tapestry component.  
But the HTML <label> tag is also not supposed to be used like that. As  
Ivan suggested, use <span> instead.

> What do i do in the case where I dont have an ID?

Don't use the Label component.

-- 
Thiago H. de Paula Figueiredo

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


Re: Label component usage

Posted by Ivan Khalopik <ik...@gmail.com>.
Label component is used in addition to t5 Field component, so for parameter
is required and Field with defined identifier should exist. In case if you
need just an html label element you can use html tag <label>. As I
understand in your code snippet you need something like <span> with some
styling:

<span class="label"> to </span>

To make your code work you should also replace expressions with properties
from java class:

<td colspan="0">
    <div style="font-weight:bold; text-align: center;">
        <t:outputRaw value="${fromValue}"/>
        <span class="label"> to </span>
        <t:outputRaw value="${toValue}"/>
        <span class="label"> of </span>
        <span class="label">${count}</span>
    </div>
</td>

public class MyComponent {
    //...

    public int getFromValue() {
        return cursor + 1;
    }

    public int getToValue() {
        return Math.min(cursor + itemsPerPage, collection.size());
    }

    public int getCount() {
        return collection.size();
    }
}

As you use just a numbers in your OutputRaw components you can replace them
with simple expression:

<td colspan="0">
    <div style="font-weight:bold; text-align: center;">
        ${fromValue}" <span class="label"> to </span> ${toValue} <span
class="label"> of </span> <span class="label">${count}</span>
    </div>
</td>

And in the end of all this, you can introduce message in your component
message catalog:

MyComponent.properties:

pager-format=%s <span class="label"> to </span> %s <span class="label"> of
</span> <span class="label">%s</span>

MyComponent.java:

public class MyComponent {
    //...

    @Inject
    private Messages messages;

    public int getFromValue() {
        return cursor + 1;
    }

    public int getToValue() {
        return Math.min(cursor + itemsPerPage, collection.size());
    }

    public int getCount() {
        return collection.size();
    }

    public String getPagerMarkup() {
        messages.format("pager-format", getFromValue(), getToValue(),
getCount());
    }
}

MyCompoent.tml:

<td colspan="0">
    <div style="font-weight:bold; text-align: center;">
        <t:outputRaw value="${pagerMarkup}"/>
    </div>
</td>

In this case we use OutputRaw as we have html markup in the rendered value.


On Mon, Oct 1, 2012 at 8:00 AM, Ken in Nashua <kc...@live.com> wrote:

>
> If I specify autoPagingContent as the for value... it gives same error
> asking for embedded component.
>
> whats the definition of an embedded component?
>
> Any ideas how to get around this?
>
> Should I just get rid of using the Labels ?
>
> kcolassi@live.com
>
>
>
>
> From: kcolassi@live.com
> To: users@tapestry.apache.org
> Subject: Label component usage
> Date: Mon, 1 Oct 2012 00:55:52 -0400
>
>
>
>
>
> Folks,
>
> I am using the Label component to model some space maintainers in between
> the postions of components. kinda like filling up empty table columns ?
>
> <td colspan="0">
>     <div style="font-weight:bold; text-align: center;">
>         <t:Label for=""/>
>
>         <t:outputRaw value="${cursor} + 1"/>
>
>         <t:Label for=""> to </t:Label>
>
>         <t:if test="cursor">
>             <t:outputRaw value="${cursor} +
> min(collection.size,itemsPerPage) "/>
>             <p:else>
>                 <t:outputRaw value="${cursor} +
> min(collection.size,itemsPerPage) "/>
>             </p:else>
>         </t:if>
>
>         <t:Label for=""> of </t:Label>
>         <t:Label for="">collection.size</t:Label>
>         <t:Label for=""/>
>     </div>
> </td>
>
> But the Label component is being annoying. Why do I have to anchor it to
> an id with the for parameter. Is there some animation I am unexpectedly
> getting that it wants to do under the hood ?
>
> All I want to do is animate some empty NOP label spots and use a few
> labels to render some text.
>
> What do i do in the case where I dont have an ID?
>
> Thanks in advance...
>
> kcolassi@live.com
>
>
>
>
>



-- 
BR
Ivan

RE: Label component usage

Posted by Ken in Nashua <kc...@live.com>.
If I specify autoPagingContent as the for value... it gives same error asking for embedded component.

whats the definition of an embedded component?

Any ideas how to get around this?

Should I just get rid of using the Labels ?

kcolassi@live.com
 



From: kcolassi@live.com
To: users@tapestry.apache.org
Subject: Label component usage
Date: Mon, 1 Oct 2012 00:55:52 -0400





Folks,

I am using the Label component to model some space maintainers in between the postions of components. kinda like filling up empty table columns ?

<td colspan="0">
    <div style="font-weight:bold; text-align: center;">
        <t:Label for=""/>        
        
        <t:outputRaw value="${cursor} + 1"/>
        
        <t:Label for=""> to </t:Label>
        
        <t:if test="cursor">    
            <t:outputRaw value="${cursor} + min(collection.size,itemsPerPage) "/>
            <p:else>
                <t:outputRaw value="${cursor} + min(collection.size,itemsPerPage) "/>
            </p:else>                            
        </t:if>        
        
        <t:Label for=""> of </t:Label>
        <t:Label for="">collection.size</t:Label>
        <t:Label for=""/>
    </div>
</td>

But the Label component is being annoying. Why do I have to anchor it to an id with the for parameter. Is there some animation I am unexpectedly getting that it wants to do under the hood ?

All I want to do is animate some empty NOP label spots and use a few labels to render some text.

What do i do in the case where I dont have an ID?

Thanks in advance... 

kcolassi@live.com