On Mon, 09 Jun 2014 05:50:33 -0300, Net Dawg <net.d...@yahoo.com.invalid> wrote:

Has anyone used org.apache.tapestry5.corelib.components.Label within page class? I looked at the code for Lable and see method like beginRender, afterRender...nothing obvious...

Label doesn't have any logic for defining the rendered label. Actually, it takes it from the associated form field component (if (bodyIsBlank) writer.write(field.getLabel()); in afterRender()). AbstractField, the superclass of all Tapestry-provided form field components, has a label parameter. Its default value is defined by ComponentDefaultProvidoer.defaultLabel(), called inside AbstractField.defaultLabel(). So, in the end, here's the actual logic behind field labels:

    public String defaultLabel(ComponentResources resources)
    {
        Defense.notNull(resources, "resources");

        String componentId = resources.getId();
        String key = componentId + "-label";

Messages containerMessages = resources.getContainerResources().getMessages();

if (containerMessages.contains(key)) return containerMessages.get(key);

        return TapestryInternalUtils.toUserPresentable(componentId);
    }

Where the resources parameter is the ComponentResources instance of the field. Summary: it looks up an [field-id]-label message from the messages file. If found, it's used unchanged. Otherwise, it uses a method (TapestryInternalUtils.toUserPresentable()) to extract a good user-facing label from the field name, supposing it follows the Java standards for field names.

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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

Reply via email to