I'm working on the message stuff now. FYI there is a class in MyFaces
called MessageUtils that does a lot of the work for you.
On 4/2/05, Rob Decker <[EMAIL PROTECTED]> wrote:
> Here's how to do a message for a node selected by a user that was deleted.
> First create a resource bundle for the component. Something like
> Message.properties in the resources directory is good. Add a key for the
> message:
>
> com.myfaces.tree2.ITEM_DELETED=The selected item no longer exists.
>
> Optionally you can add a detail message:
>
> com.myfaces.tree2.ITEM_DELETED_detail=The selected item was deleted from
> the tree. \
> Please select another item.
>
> In the component where you want to set the message, first get the resource
> bundle for the application:
>
> Application application = context.getApplication();
> String bundleName = application.getMessageBundle();
> Locale locale =
> FacesContext.getCurrentInstance().getViewRoot().getLocale();
> ResourceBundle rb = ResourceBundle.getBundle(bundleName, locale);
>
> Then get the component's bundle (note I shorted the package path for
> brevity):
>
> ResourceBundle crb =
> ResourceBundle.getBundle("com.myfaces...tree2.resource.Messages",
> locale);
>
> Always check the application bundle first for the message so the end user
> can override the message with their own version.
>
> String msg = rb.getString("com.myfaces.tree2.ITEM_DELETED");
> String dmsg = rb.getString("com.myfaces.tree2.ITEM_DELETED_detail");
> if (msg == null) msg = crb.getString("com.myfaces.tree2.ITEM_DELETED");
> if (dmsg == null) dmsg =
> crb.getString("com.myfaces.tree2.ITEM_DELETED_detail");
>
> Create a FacesMessage and add it to the FacesContext message queue:
>
> FacesMessage fmsg = new FacesMessage.SEVERITY_INFO, msg, dmsg);
> FacesContext.getCurrentInstance().addMessage(tree2Id, fmsg);
>
> The tree2Id param can be the id attribute of the tree2 tag to associate the
> message with the tree.
>
>
> Rob