Hello,
I was missing a t:messages component as I want to show 'entry was
deleted' 'entry was saved ...' messages directly or after a redirect.

I wrote my own one but it is not very beautiful. It uses a application
state object stored into the session 'MessageStore'. I inject the
message store into my page class, add messages and the component reads
the messages. The reading of the messages deletes them from the store.

Currently, I need to inject two objects into a page class
@SessionState(create = true)
    private MessagesStore messagesStore;

    @Inject
    private Messages messages;

public Object onSuccess(){
            messagesStore.textMessage(messages.get("foo"));
 return null;
}

I would like to inject only one object and use it like
  messageStore.message("foo");
in order to get the "foo" message from the resources.

Do you have any ideas how to achieve this?

Best Regards

Sebastian Hennebrueder

Below you can find the component class.


The component class
public class Messages {

    @SessionState
    private MessagesStore messagesStore;

    private List<String> messages;

    @Property
    private String message;

    @BeginRender
    boolean beginRender(){
        if(messagesStore.empty())
                return false;
        messages = messagesStore.getMessages();
        return true;
    }

    public List<String> getMessages() {
        return messages;
    }
}
Component template
<body xmlns="http://www.w3.org/1999/xhtml";
            xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd";>

<ul class="messages">
    <t:loop source="messages" value="message">
        <li>${message}</li>
    </t:loop>
</ul>
</body>



--
Best Regards / Viele Grüße

Sebastian Hennebrueder
-----
Software Developer and Trainer for Hibernate / Java Persistence
http://www.laliluna.de



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

Reply via email to