incubator-adffaces-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Lowe" <chris.lowe...@gmail.com>
Subject Re: tr:messages with detailed message
Date Tue, 20 Feb 2007 22:42:33 GMT
Thomas,

I'd also be interested in any information on this.  I've found myself using
the following phase listener to hack around situation by setting the message
summary to the value for the detail.  I know, I know - it ain't pretty but
I'd rather some design smell rather than just showing "Value required" at
the global message (<tr:messages/>) level.

Regards,

Chris.


import java.util.Iterator;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext ;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;

public class MessageCustomisationListener implements PhaseListener
{
  public MessageCustomisationListener() {
  }


  public PhaseId getPhaseId() {
    return PhaseId.RENDER_RESPONSE;
  }


  public void beforePhase(final PhaseEvent phaseEvent) {
    final FacesContext context = phaseEvent.getFacesContext();

    final Iterator itr = context.getClientIdsWithMessages();

    if (!itr.hasNext()) {
      // no messages, so nothing to do
      return;
    }

    final UIViewRoot uiViewRoot = context.getViewRoot();

    while (itr.hasNext()) {
      final String clientId = (String) itr.next();

      if (clientId == null) {
        continue;
      }

      final UIComponent component = uiViewRoot.findComponent (clientId);

      if (component == null) {
        // If a session times out while a message is being thrown, a
component
        // will be returned as null if the user attempts to interact with
the
        // app.
        return;
      }

      final Iterator itr2 = context.getMessages(clientId);

      while (itr2.hasNext()) {
        final FacesMessage msg = (FacesMessage) itr2.next();

        msg.setSummary(msg.getDetail());
      }
    }
  }

  public void afterPhase(PhaseEvent e) {
  }
}



On 19/02/07, Thomas Hamacher <thamacher@project-team.de> wrote:
>
> Hi @all,
>
> does anyone know, why the messages given through the
> requiredMessage=""-attribute does not show up with the detailed message
> text, but only the standard-short version when showing them through the
> <tr:messages />-tag, but only near the input-field? Is there any option I
> can set or is this simply not supported? I think it is a little bit
> confusing, when the messages, displayed through tr:messages are different
> than the error-messages near the field.
>
> Any help would be greately appriciated.
>
> Thanks so far
> Thomas
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message