Author: ajaquith
Date: Sat Mar 27 15:40:06 2010
New Revision: 928220
URL: http://svn.apache.org/viewvc?rev=928220&view=rev
Log:
Renamed EventResolution to AjaxResolution (I had made changes similar to
AJAX/JSON to his, independently).
Added:
incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/AjaxResolution.java
- copied, changed from r925813,
incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/EventResolution.java
Removed:
incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/EventResolution.java
Modified:
incubator/jspwiki/trunk/ChangeLog
incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditActionBean.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditDialogActionBean.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/action/InstallActionBean.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/AjaxEvent.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiInterceptor.java
Modified: incubator/jspwiki/trunk/ChangeLog
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=928220&r1=928219&r2=928220&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Sat Mar 27 15:40:06 2010
@@ -1,3 +1,10 @@
+2010-03-27 Andrew Jaquith <ajaquith AT apache DOT org>
+
+ * 3.0.0-svn-217
+
+ * Renamed EventResolution to AjaxResolution (I had made changes
+ similar to AJAX/JSON to his, independently).
+
2010-03-21 Dirk Frederickx <[email protected]>
* v3.0.0-svn-216 : AJAX/JSON fixes.
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java?rev=928220&r1=928219&r2=928220&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/Release.java Sat Mar 27
15:40:06 2010
@@ -77,7 +77,7 @@ public final class Release
* <p>
* If the build identifier is empty, it is not added.
*/
- public static final String BUILD = "216";
+ public static final String BUILD = "217";
/**
* This is the generic version string you should use
Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditActionBean.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditActionBean.java?rev=928220&r1=928219&r2=928220&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditActionBean.java
(original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditActionBean.java
Sat Mar 27 15:40:06 2010
@@ -101,11 +101,11 @@ public class EditActionBean extends Abst
private long m_startTime = -1;
/**
- * AJAX event handler that returns an {...@link EventResolution} containing
+ * AJAX event handler that returns an {...@link AjaxResolution} containing
* a preview of the page contents, as submitted by the {...@code wikiText}
* field.
*
- * @return always returns a {...@link EventResolution} containing the
+ * @return always returns an {...@link AjaxResolution} containing the
* results
*/
@AjaxEvent
@@ -124,8 +124,8 @@ public class EditActionBean extends Abst
// Get the text directly from the RenderingManager, without caching
String result = renderer.getHTML( context, doc );
- // Return an EventResolution
- Resolution r = new EventResolution( context, result );
+ // Return an AjaxResolution
+ Resolution r = new AjaxResolution( context, result );
return r;
}
Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditDialogActionBean.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditDialogActionBean.java?rev=928220&r1=928219&r2=928220&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditDialogActionBean.java
(original)
+++
incubator/jspwiki/trunk/src/java/org/apache/wiki/action/EditDialogActionBean.java
Sat Mar 27 15:40:06 2010
@@ -11,7 +11,7 @@ import org.apache.wiki.log.Logger;
import org.apache.wiki.log.LoggerFactory;
import org.apache.wiki.parser.MarkupParser;
import org.apache.wiki.providers.ProviderException;
-import org.apache.wiki.ui.stripes.EventResolution;
+import org.apache.wiki.ui.stripes.AjaxResolution;
public class EditDialogActionBean extends AbstractActionBean
{
@@ -24,7 +24,7 @@ public class EditDialogActionBean extend
*
* @param wikiName the page name
* @param maxLength maximum number of suggestions
- * @return an EventResolution containing the suggestions as a JavaScript
array of Strings
+ * @return an AjaxResolution containing the suggestions as a JavaScript
array of Strings
*/
@DefaultHandler
@HandlesEvent( "suggestions" )
@@ -80,6 +80,6 @@ public class EditDialogActionBean extend
log.debug("Suggestion request for "+wikiName+" done in "+sw );
}
- return new EventResolution( getContext(), list );
+ return new AjaxResolution( getContext(), list );
}
}
Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/action/InstallActionBean.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/InstallActionBean.java?rev=928220&r1=928219&r2=928220&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/java/org/apache/wiki/action/InstallActionBean.java
(original)
+++
incubator/jspwiki/trunk/src/java/org/apache/wiki/action/InstallActionBean.java
Sat Mar 27 15:40:06 2010
@@ -625,7 +625,7 @@ public class InstallActionBean extends A
/**
* AJAX event method that tests LDAP authentication based on the bind-user
- * settings, returning an {...@link EventResolution} whose response object
is
+ * settings, returning an {...@link AjaxResolution} whose response object
is
* an array of strings.
*
* @return the results
@@ -643,7 +643,7 @@ public class InstallActionBean extends A
/**
* AJAX event method that tests the connection to the LDAP server,
returning
- * an {...@link EventResolution} whose response object is
+ * an {...@link AjaxResolution} whose response object is
* an array of strings.
*
* @return the results
@@ -669,12 +669,12 @@ public class InstallActionBean extends A
errors.addGlobalError( new SimpleError( " Cause: " +
e.getCause().getMessage() ) );
}
}
- return new EventResolution( getContext() );
+ return new AjaxResolution( getContext() );
}
/**
* AJAX event method that tests the LDAP role lookups based on the
- * configured user base, returning an {...@link EventResolution}
+ * configured user base, returning an {...@link AjaxResolution}
* whose response object is an array of strings.
*
* @return the results
@@ -713,12 +713,12 @@ public class InstallActionBean extends A
errors.addGlobalError( new SimpleError( " Cause: " +
e.getCause().getMessage() ) );
}
}
- return new EventResolution( getContext() );
+ return new AjaxResolution( getContext() );
}
/**
* AJAX event method that tests the LDAP user lookups based on the
- * configured user base, returning an {...@link EventResolution} whose
+ * configured user base, returning an {...@link AjaxResolution} whose
* response object is an array of strings.
*
* @return the results
@@ -762,7 +762,7 @@ public class InstallActionBean extends A
errors.addGlobalError( new SimpleError( " Cause: " +
e.getCause().getMessage() ) );
}
}
- return new EventResolution( getContext() );
+ return new AjaxResolution( getContext() );
}
/**
Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java?rev=928220&r1=928219&r2=928220&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
(original)
+++
incubator/jspwiki/trunk/src/java/org/apache/wiki/action/SearchActionBean.java
Sat Mar 27 15:40:06 2010
@@ -37,7 +37,7 @@ import org.apache.wiki.log.Logger;
import org.apache.wiki.log.LoggerFactory;
import org.apache.wiki.search.SearchResult;
import org.apache.wiki.ui.stripes.AjaxEvent;
-import org.apache.wiki.ui.stripes.EventResolution;
+import org.apache.wiki.ui.stripes.AjaxResolution;
import org.apache.wiki.ui.stripes.TemplateResolution;
import org.apache.wiki.ui.stripes.WikiRequestContext;
@@ -215,7 +215,7 @@ public class SearchActionBean extends Ab
* for this ActionBean. Results are streamed back to the client as an array
* of JSON-encoded SearchResult objects.
*
- * @return always returns an {...@link EventResolution} containing the
+ * @return always returns an {...@link AjaxResolution} containing the
* results; this may be a zero-length array
*/
@AjaxEvent
@@ -229,7 +229,7 @@ public class SearchActionBean extends Ab
/**
* AJAX event method that provides quick-search used in {...@code
SearchBox.jsp}.
*
- * @return a {...@link EventResolution} containing HTML to be inserted
into an
+ * @return an {...@link AjaxResolution} containing HTML to be inserted
into an
* element.
*/
@AjaxEvent
@@ -242,7 +242,7 @@ public class SearchActionBean extends Ab
// So, for now, still using manual conversion to html
// iso straight translation to json object.
//
- //return new EventResolution( getContext(), m_results );
+ //return new AjaxResolution( getContext(), m_results );
String html = null;
StringBuilder b = new StringBuilder();
@@ -260,7 +260,6 @@ public class SearchActionBean extends Ab
b.append( "</ul>" );
html = b.toString();
}
- return new EventResolution( getContext(), html );
-
+ return new AjaxResolution( getContext(), html );
}
}
Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/AjaxEvent.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/AjaxEvent.java?rev=928220&r1=928219&r2=928220&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/AjaxEvent.java
(original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/AjaxEvent.java
Sat Mar 27 15:40:06 2010
@@ -6,7 +6,7 @@ import java.lang.annotation.*;
* Method-level annotation indicating that an event is an AJAX event. Any
* validation errors will be intercepted after the
* {...@link
net.sourceforge.stripes.controller.LifecycleStage#CustomValidation}
- * stage and returned as an {...@link
org.apache.wiki.ui.stripes.EventResolution}.
+ * stage and returned as an {...@link
org.apache.wiki.ui.stripes.AjaxResolution}.
*/
@Documented
@Inherited
Copied:
incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/AjaxResolution.java
(from r925813,
incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/EventResolution.java)
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/AjaxResolution.java?p2=incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/AjaxResolution.java&p1=incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/EventResolution.java&r1=925813&r2=928220&rev=928220&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/EventResolution.java
(original)
+++
incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/AjaxResolution.java
Sat Mar 27 15:40:06 2010
@@ -11,26 +11,23 @@ import javax.servlet.http.HttpServletRes
import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.Message;
import net.sourceforge.stripes.action.Resolution;
-
-import org.json.JSONObject;
-
import net.sourceforge.stripes.controller.StripesFilter;
import net.sourceforge.stripes.tag.ErrorsTag;
import net.sourceforge.stripes.tag.MessagesTag;
import net.sourceforge.stripes.validation.ValidationError;
import net.sourceforge.stripes.validation.ValidationErrors;
+import org.json.JSONObject;
+
/**
* <p>
- * Resolution that returns an {...@code eval}-able set of JavaScript statements
- * that builds a variable containing the result of an AJAX call. The object is
- * called {...@code eventResponse} and contains the call results, the
- * ActionBeanContext messages and validation errors. It has four properties:
+ * Resolution that returns a JSON-encoded object that contains the call
results, the
+ * ActionBeanContext messages and validation errors. It has three properties:
* </p>
* <ul>
* <li>{...@code results} - the Object (or an array of Objects) that represents
* the results of the AJAX call. The object or objects can be just about
anything that
- * {...@link net.sourceforge.stripes.ajax.JavaScriptBuilder} can encode.
+ * {...@link org.json.JSONObject} can encode.
* It is most commonly a single HTML string.</li>
* <li>{...@code errors} - any global or field-level errors, as an HTML
string. If
* no errors, this property will be {...@code null}</li>
@@ -50,7 +47,7 @@ import net.sourceforge.stripes.validatio
* stripes.messages.afterMessage} and {...@code stripes.messages.footer} are
used.
* </p>
*/
-public class EventResolution implements Resolution
+public class AjaxResolution implements Resolution
{
/**
* Lightweight class that represents the result of an AJAX call, including
@@ -62,16 +59,16 @@ public class EventResolution implements
private final String m_messages;
- private final Object m_rootObject;
+ private final Object m_result;
/**
- * Constructs a new EventResolution.
+ * Constructs a new AjaxResolution.
*
* @param context the ActionBeanContext that supplies the messages and
* validation errors.
- * @param objects zero or more Objects to be returned
+ * @param object a JavaBean, String or Map object to be returned
*/
- public Result( ActionBeanContext context, Object... objects )
+ public Result( ActionBeanContext context, Object object )
{
super();
@@ -81,19 +78,8 @@ public class EventResolution implements
// Set the validation errors
m_errors = context.getValidationErrors().size() > 0 ?
generateErrors( context ) : null;
- // Set the root object
- if ( objects.length == 1 )
- {
- m_rootObject = objects[0];
- }
- else if ( objects.length > 0 )
- {
- m_rootObject = objects;
- }
- else
- {
- m_rootObject = null;
- }
+ // Set the result object
+ m_result = object;
}
/**
@@ -122,11 +108,11 @@ public class EventResolution implements
* was passed, that object will be returned. Otherwise, an array of
* objects will be returned.
*
- * @return the root object; {...@code null}, one object, or an array
of objects
+ * @return the result object, with will always be a JavaBean, String,
or Map
*/
public Object getResults()
{
- return m_rootObject;
+ return m_result;
}
/**
@@ -224,35 +210,41 @@ public class EventResolution implements
private final JSONObject m_jsonobject;
/**
- * Constructs a new EventResolution for a supplied ActionBeanContext and
- * result objects.
+ * Constructs a new AjaxResolution for a supplied ActionBeanContext and
+ * {...@code null} result object. The ActionBean messages, validation
errors and result
+ * object are wrapped with a {...@link Result} object. This constructor is
+ * used when returning messages or validation errors only, without a
response
+ * body.
+ * @param context the ActionBeanContext
+ */
+ public AjaxResolution( ActionBeanContext context )
+ {
+ this( context, null );
+ }
+
+ /**
+ * Constructs a new AjaxResolution for a supplied ActionBeanContext and
+ * result object. The ActionBean messages, validation errors and result
+ * object are wrapped with a {...@link Result} object.
* @param context the ActionBeanContext
- * @param objects zero, one or more objects that represent the result
+ * @param object a JavaBean, String or Map that represents the result
* of an {...@link org.apache.wiki.ui.stripes.AjaxEvent}-annotated
* event method
*/
- public EventResolution( ActionBeanContext context, Object... objects )
+ public AjaxResolution( ActionBeanContext context, Object object )
{
-
- //FIXME: returning JSON object iso JavascriptResolution
- m_jsonobject = new JSONObject( new Result(context, objects) );
-
+ m_jsonobject = new JSONObject( new Result( context, object ) );
}
/**
- * Converts the ActionBean messges, validation errors and root object
passed
- * in to a series of JavaScript statements that reconstruct the
- * {...@link Result} object in JavaScript, and store the object under the
- * variable name {...@code eventResponse}.
+ * Converts the {...@link Result} object that represents the ActionBean
messages,
+ * validation errors and result passed in the constructor
+ * into a JSON-encoded object.
*/
public void execute( HttpServletRequest request, HttpServletResponse
response ) throws Exception
{
-
response.setContentType( "application/json" );
-
m_jsonobject.write( response.getWriter() );
-
response.flushBuffer();
-
}
}
Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiInterceptor.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiInterceptor.java?rev=928220&r1=928219&r2=928220&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiInterceptor.java
(original)
+++
incubator/jspwiki/trunk/src/java/org/apache/wiki/ui/stripes/WikiInterceptor.java
Sat Mar 27 15:40:06 2010
@@ -355,7 +355,7 @@ public class WikiInterceptor implements
* <p>
* To ensure that AJAX-related validation errors are handled correctly, if
the
* current event method is annotated with {...@link
org.apache.wiki.ui.stripes.AjaxEvent},
- * an {...@link org.apache.wiki.ui.stripes.EventResolution} will be
returned
+ * an {...@link org.apache.wiki.ui.stripes.AjaxResolution} will be returned
* if one or more validation errors were generated earlier in the
lifecycle.
* </p>
* <p>
@@ -397,7 +397,7 @@ public class WikiInterceptor implements
Method handler = context.getHandler();
if ( handler.getAnnotation( AjaxEvent.class ) != null && errors.size()
> 0 )
{
- return new EventResolution( actionBeanContext );
+ return new AjaxResolution( actionBeanContext );
}
// Get the event handler method