Changeset 234:142018e051a1

Show
Ignore:
Timestamp:
08/31/09 15:00:15 (4 years ago)
Author:
tgambet
Branch:
default
convert_revision:
svn:cdcfb263-7567-472c-a848-e2c2df3466e7/trunk@235
Message:

unicorn now displays error messages on the index page instead of a dedicated page

Files:
1 added
5 modified

Legend:

Unmodified
Added
Removed
  • WebContent/WEB-INF/resources/templates/index.vm

    r214 r234  
    1212#end 
    1313 
     14#if ($message) 
     15        <div id="messages"> 
     16                <div class="error"> 
     17                        <h4>$message.Message</h4> 
     18                        #if ($message.Content) 
     19                        <pre>$message.Content</pre> 
     20                        #end 
     21                </div> 
     22        </div> 
     23#end 
    1424        <div id="frontforms"> 
    1525                <ul id="tabset_tabs"> 
  • WebContent/scripts/w3c_unicorn_index.js

    r214 r234  
    6363                W3C.TaskOptions.addEvent('mouseout', function() { 
    6464                        W3C.TaskDescrip.set('text', W3C.TaskOptions[W3C.SelectedTask].title); 
     65                }); 
     66                 
     67                $$('div.error').addClass('pointer'); 
     68                 
     69                $$('div.error pre').slide('hide'); 
     70                 
     71                $$('div.error').each(function(error) { 
     72                        error.addEvent('click', function(event) { 
     73                                error.getElement('pre').slide('toggle'); 
     74                        }); 
    6575                }); 
    6676                 
  • WebContent/style/base_ucn.css

    r228 r234  
    304304        color:#A3756E; 
    305305} 
    306  
    307 /* After javascript */ 
     306#messages { 
     307        padding:0.8em; 
     308        font-size:0.9em; 
     309        border:3px solid #FBC2C4; 
     310        background: #FBE3E4; 
     311        color:#8A1F11; 
     312        margin:1.2em 2.3em; 
     313} 
     314#messages .error { 
     315         
     316} 
     317#messages .error h4 { 
     318        line-height:18px; 
     319        padding-left:22px; 
     320        background:url(../images/icone_error.png) no-repeat scroll left top; 
     321} 
     322#messages .error pre { 
     323        padding-top:0.6em; 
     324} 
     325#messages .pointer:hover h4 { 
     326        text-decoration: underline; 
     327} 
     328 
     329/* Post-javascript */ 
    308330fieldset.toggles legend { 
    309331        background:url(../images/arrow-closed.png) no-repeat scroll 0.2em 0.35em; 
     
    316338        cursor: pointer; 
    317339} 
    318 #observations .pointer { 
     340.pointer { 
    319341        cursor: pointer; 
    320342} 
  • src/org/w3c/unicorn/action/IndexAction.java

    r230 r234  
    1010import org.w3c.unicorn.Framework; 
    1111import org.w3c.unicorn.language.Language; 
     12import org.w3c.unicorn.util.Message; 
    1213import org.w3c.unicorn.util.Property; 
    1314import org.w3c.unicorn.util.Templates; 
     
    4748                velocityContext.put("current_task", Framework.mapOfTask.get(taskParameter)); 
    4849                 
     50                if (req.getAttribute("unicorn_message") != null) 
     51                        //System.out.println("TOM: " + ((Message) req.getAttribute("unicorn_message")).getMessage()); 
     52                        velocityContext.put("message", req.getAttribute("unicorn_message")); 
     53                 
    4954                if (req.getHeader("X-Requested-With") != null && req.getHeader("X-Requested-With").equals("XMLHttpRequest")) { 
    5055                        //for JavaScript testing purposes 
  • src/org/w3c/unicorn/action/ObserveAction.java

    r230 r234  
    1 // $Id: ObserveAction.java,v 1.3 2009-08-31 11:59:09 tgambet Exp $ 
     1// $Id: ObserveAction.java,v 1.4 2009-08-31 15:00:15 tgambet Exp $ 
    22// Author: Jean-Guilhem Rouel 
    33// (c) COPYRIGHT MIT, ERCIM and Keio, 2006. 
     
    3737import org.w3c.unicorn.output.OutputFormater; 
    3838import org.w3c.unicorn.output.OutputModule; 
     39import org.w3c.unicorn.util.Message; 
    3940import org.w3c.unicorn.util.Property; 
    4041 
     
    9899                logger.debug("Lang Parameter: " + langParameter); 
    99100                 
    100                 //velocityContext = new VelocityContext(Language.getContext(langParameter)); 
     101                 
    101102                 
    102103                // Variables related to the output 
     
    125126                        this.addParameter(sParamName, tStringParamValue, aUnicornCall, 
    126127                                        mapOfSpecificParameter, mapOfOutputParameter); 
    127                 } // For 
    128  
    129                 if (aUnicornCall.getTask() == null) { 
     128                } 
     129                 
     130                if (aUnicornCall.getTask() == null) 
     131                        aUnicornCall.setTask(Framework.mapOfTask.getDefaultTaskId()); 
     132 
     133                /*if (aUnicornCall.getTask() == null) { 
    130134                        ObserveAction.logger.error("No task selected."); 
    131135                        this.createError(resp, new NoTaskException(), 
    132136                                        mapOfSpecificParameter, mapOfOutputParameter); 
    133137                        return; 
    134                 } 
    135  
     138                }*/ 
     139                 
     140                 
    136141                try { 
    137142                        aUnicornCall.doTask(); 
     
    142147                        ObserveAction.logger.error("Exception : " + aException.getMessage(), 
    143148                                        aException); 
    144                         this.createError(resp, aException, 
    145                                         mapOfSpecificParameter, mapOfOutputParameter); 
     149                         
     150                        if (mapOfOutputParameter.get("format").equals("xhtml10")) { 
     151                                String errorMessage = (String) Framework.getLanguageProperties().get(langParameter).get("stack_trace_text"); 
     152                                String errorContent = ""; 
     153                                errorContent += aException.getMessage() + "\n"; 
     154                                for (StackTraceElement stackTraceElement : aException.getStackTrace()) { 
     155                                        errorContent += stackTraceElement.toString() + "\n"; 
     156                                } 
     157                                Message mess = new Message(Message.Level.ERROR, errorMessage, errorContent); 
     158                                req.setAttribute("unicorn_message", mess); 
     159                                (new IndexAction()).doGet(req, resp); 
     160                                 
     161                        } else { 
     162                                this.createError(resp, aException, mapOfSpecificParameter, mapOfOutputParameter); 
     163                        } 
     164                         
    146165                } 
    147166        } 
     
    235254                        ObserveAction.logger.error("Exception : " + aException.getMessage(), 
    236255                                        aException); 
    237                         this.createError(resp, aException, 
    238                                         mapOfSpecificParameter, mapOfOutputParameter); 
     256                         
     257                        if (mapOfOutputParameter.get("format").equals("xhtml10")) { 
     258                                (new IndexAction()).doGet(req, resp); 
     259                        } else { 
     260                                this.createError(resp, aException, mapOfSpecificParameter, mapOfOutputParameter); 
     261                        } 
     262                         
    239263                } finally { 
    240264                        if ("true".equals(Property.get("DELETE_UPLOADED_FILES"))