You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "hongbing wang (JIRA)" <de...@myfaces.apache.org> on 2011/02/16 21:04:25 UTC

[jira] Created: (TRINIDAD-2038) Need new exception wrapper to know whether JSF needs to report the exception

Need new exception wrapper to know whether JSF needs to report the exception
----------------------------------------------------------------------------

                 Key: TRINIDAD-2038
                 URL: https://issues.apache.org/jira/browse/TRINIDAD-2038
             Project: MyFaces Trinidad
          Issue Type: Bug
    Affects Versions: 2.0.0-beta-1
            Reporter: hongbing wang


There are cases that exception is thrown in update model phase, like model layer validation failure, by model outside of JSF and the exception is also handled and reported outside of JSF. To avoid the component's local value getting reset to null, JSF needs to be notified. The proposed solution is to re-throw a wrappered exception to JSF and also let JSF to know whether it needs to report the exception.

Here is the interface of the wrapper:
package org.apache.myfaces.trinidad.context;

/**
 * Interface for exceptions that tells whether the exception needs to be reported.
 * If an exception is thrown during JSF lifycycle and aleady reported, then it should let
 * JSF know not to report it again.
 *
 */
public interface ExceptionWrapper
{
  
  /**
   * Return false if JSF doesn't need to report this exception, otherwise ture.
   */
  public boolean isReportingMessage();
  
}  

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (TRINIDAD-2038) Need new exception to know whether JSF needs to report the exception

Posted by "Pavitra Subramaniam (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/TRINIDAD-2038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12995502#comment-12995502 ] 

Pavitra Subramaniam commented on TRINIDAD-2038:
-----------------------------------------------

Hello Hongbing, 

You mentioned that exceptions get thrown by model layer outside of JSF. Can you give an e.g., of when this might occur? 
How exactly will the above interface get used?

Thanks
Pavitra



> Need new exception to know whether JSF needs to report the exception
> --------------------------------------------------------------------
>
>                 Key: TRINIDAD-2038
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-2038
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta-1
>            Reporter: hongbing wang
>
> There are cases that exception is thrown in update model phase, like model layer validation failure, by model outside of JSF and the exception is also handled and reported outside of JSF. To avoid the component's local value getting reset to null, JSF needs to be notified when the it happens. The proposed solution is to re-throw a special exception to JSF and also let JSF to know whether it needs to report the exception.
> Here is the interface of the exception:
> package org.apache.myfaces.trinidad.context;
> /**
>  * Interface for exceptions that tells whether the exception needs to be reported.
>  * If an exception is thrown during JSF lifycycle and aleady reported, then it should let
>  * JSF know not to report it again.
>  *
>  */
> public interface Reportable
> {
>   
>   /**
>    * Return false if JSF doesn't need to report this exception, otherwise true.
>    */
>   public boolean isReportingMessage();
>   
> }  

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Updated: (TRINIDAD-2038) Need new exception to know whether JSF needs to report the exception

Posted by "hongbing wang (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/TRINIDAD-2038?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

hongbing wang updated TRINIDAD-2038:
------------------------------------

    Status: Patch Available  (was: Open)

> Need new exception to know whether JSF needs to report the exception
> --------------------------------------------------------------------
>
>                 Key: TRINIDAD-2038
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-2038
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta-1
>            Reporter: hongbing wang
>
> There are cases that exception is thrown in update model phase, like model layer validation failure, by model outside of JSF and the exception is also handled and reported outside of JSF. To avoid the component's local value getting reset to null, JSF needs to be notified when it happens. The proposed solution is to re-throw a special exception to JSF notify it and also let JSF know whether it needs to report the exception.
> Here is the interface of the exception:
> package org.apache.myfaces.trinidad.context;
> /**
>  * Interface for exceptions that tells whether the exception needs to be reported.
>  * If an exception is thrown during JSF lifycycle and already reported, then it should let
>  * JSF know not to report it again.
>  *
>  */
> public interface Reportable
> {
>   
>   /**
>    * Return false if JSF doesn't need to report this exception, otherwise true.
>    */
>   public boolean isReportingMessage();
>   
> }  
> Update UIXEditableValue.updateModel(FacesContext context) to take advantage of this API as following
>   public void updateModel(FacesContext context)
>   {
>       ...
>       setValid(false);
>       // don't report the exception if the exception is a Reportable instance and tells so
>       boolean isReportingMessage = (e instanceof Reportable) ?
>                                    ((Reportable) e).isReportingMessage() :
>                                    true;
>       if (isReportingMessage)
>       {
>         FacesMessage message = MessageFactory.getMessage(e);
>         message = _wrapMessage(message);
>         context.addMessage(getClientId(context), message);
>       }
>     }

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (TRINIDAD-2038) Need new exception to know whether JSF needs to report the exception

Posted by "Scott O'Bryan (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/TRINIDAD-2038?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12995609#comment-12995609 ] 

Scott O'Bryan commented on TRINIDAD-2038:
-----------------------------------------

Also, by JSF, I'm assuming that you mean the Trinidad renderkit and NOT JSF itself.

In general, I think I would prefer to have a new exception rather then making exception logic more complex..  What exactly does the "interface" gain us here?

> Need new exception to know whether JSF needs to report the exception
> --------------------------------------------------------------------
>
>                 Key: TRINIDAD-2038
>                 URL: https://issues.apache.org/jira/browse/TRINIDAD-2038
>             Project: MyFaces Trinidad
>          Issue Type: Bug
>    Affects Versions: 2.0.0-beta-1
>            Reporter: hongbing wang
>
> There are cases that exception is thrown in update model phase, like model layer validation failure, by model outside of JSF and the exception is also handled and reported outside of JSF. To avoid the component's local value getting reset to null, JSF needs to be notified when it happens. The proposed solution is to re-throw a special exception to JSF notify it and also let JSF know whether it needs to report the exception.
> Here is the interface of the exception:
> package org.apache.myfaces.trinidad.context;
> /**
>  * Interface for exceptions that tells whether the exception needs to be reported.
>  * If an exception is thrown during JSF lifycycle and already reported, then it should let
>  * JSF know not to report it again.
>  *
>  */
> public interface Reportable
> {
>   
>   /**
>    * Return false if JSF doesn't need to report this exception, otherwise true.
>    */
>   public boolean isReportingMessage();
>   
> }  

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira