users@javaserverfaces.java.net

RE: Re: JSF 1.2_04: Still unable to display FacesMessage from Java code for a h:message with an ID

From: Todd Patrick <Todd.Patrick_at_dtn.com>
Date: Tue, 13 Mar 2007 13:13:25 -0500

Imre:

I see what your saying.

I'll add the binding attribute.

Thanks,

--Todd

-----Original Message-----
From: Imre Oßwald [mailto:ioss_at_mx.jevelopers.com]
Sent: Tuesday, March 13, 2007 12:29 PM
To: users_at_javaserverfaces.dev.java.net
Subject: Re: JSF 1.2_04: Still unable to display FacesMessage from Java code for a h:message with an ID

<h:message for="filter" will display messages for the component with id="filter"
as you are adding a global message to the context it should not show up there, instead if everything else works you can display the (all)
message(s) with: <h:messages
or you have to "bind" the message to the filter component.

Hope this helps,
Imre

Am 13.03.2007 um 16:43 schrieb Todd Patrick:

> In my JSP, I have the following:
>
> <h:message id="searchErrorFilter"
> for="filter"
> showDetail="true"
> showSummary="true"
> styleClass="Error"/>
>
> I've followed "Call Application.getMessageBundle(). If non-null,
> locate the named ResourceBundle, using the Locale from the current
> UIViewRoot and see if it has a value for the argument messageId. If it
> does, treat the value as the summary of the FacesMessage. If it does
> not, or if
> Application.getMessageBundle() returned null, look in the
> ResourceBundle named by the value of the constant FACES_MESSAGES and
> see if it has a value for the argument messageId. If it does, treat
> the value as the summary of the FacesMessage. If it does not, there is
> no initialization information for the FacesMessage instance."
>
> But, it looks like I don't have an initialization happening for the
> FacesMessage in my Backing Bean.
>
> In my Java Code, I have the following method:
>
> private void doElementSearch(String _tbTransactID){
> FacesContext context = FacesContext.getCurrentInstance();
> FacesMessage message = new FacesMessage();
>
> List<ElementRow> elementResults;
> List<ElementNode> elementRoot;
> try {
> elementResults =
> transactionBrowserSessionRemote.doElementSearch(_tbTransactID);
> elementRoot = new ArrayList<ElementNode>();
>
> if (elementResults.isEmpty()) {
> ElementNode elementRootNullItem = new ElementNode();
> elementRoot.add(elementRootNullItem);
> } else {
> elementRoot.clear();
> for (ElementRow elementRow : elementResults) {
> ElementNode elementRootItem = new
> ElementNode(elementRow.getElementKey(), elementRow.getElementKey());
> elementRoot.add(elementRootItem);
> }
> }
>
> /**
> * This controls whether to display the folder icon or not
> for a leaf node
> */
> this.setElementModel(new ChildPropertyTreeModel
> (elementRoot,
> "children") {
> public boolean isContainer() {
> return ((ElementNode)getRowData()).getChildCount
> () >
> 0;
> }
> }
> );
>
> } catch (PetroException ex) {
> message.setSeverity(FacesMessage.SEVERITY_ERROR);
> message.setSummary(ex.getMessage());
> context.addMessage(null, message);
> context.getCurrentInstance().renderResponse();
>
> logger.error("Transaction Browser Exception - Element
> Tree:", ex);
> }
>
> context.renderResponse();
> }
>
>
> When I step through the code in Netbeans 5.5, context does get the
> message object added, so I can't figure out why I can't display the
> message's summary in the h:message component?
>
> I'd greatly appreciate any help, I've spent a good chunk of time on
> this issue already.
>
> Thanks,
>
> --Todd
>
> -----------------------------------------
> NOTICE: This email message is for the sole use of the intended
> recipient(s) and may contain confidential and privileged information.
> Any unauthorized use, disclosure or distribution is prohibited. If you
> are not the intended recipient, please contact the sender by reply
> email and destroy all copies of the original message.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail: users-
> help_at_javaserverfaces.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_javaserverfaces.dev.java.net
For additional commands, e-mail: users-help_at_javaserverfaces.dev.java.net