Groovy runs at javascript in the browser?  Is that correct?

I added the redirect line below the rename line and it didn't work.

{{groovy}}
import org.xwiki.observation.*
import org.xwiki.observation.event.*
import org.xwiki.bridge.event.*
import org.xwiki.context.*
import com.xpn.xwiki.web.*
import com.xpn.xwiki.*
import org.apache.velocity.VelocityContext;

class ProcessDocumentRenamer implements EventListener
{
    def xwiki
    def context
  
    ProcessDocumentRenamer(xwiki, context)
    {
        this.xwiki = xwiki
        this.context = context
    }

    String getName()
    {
        // The unique name of this event listener
        return "ProcessDocumentRenamer"
    }

    List<Event> getEvents()
    {
        // The list of events this listener listens to
        return Arrays.asList(new DocumentCreatedEvent(), new
DocumentUpdatedEvent())
    }

    // Called by the Observation Manager when an event matches the list of
events returned
    // by getEvents()
    void onEvent(Event event, Object source, Object data)
    {
        // Current context
        def crtContext =
Utils.getComponent(Execution.class).getContext().getProperty('xwikicontext')

        // Defines the type of object that should be looked for
        def myObject =
source.getObject("DocumentationTemplates.ProcessClass");

        // If the page has an object of the specified class, we get the
value of the relevant property and assign it to our title variable
        if (myObject != null) {
          // Defines the variable that we will later use to update the title
of the document
          def documentName = myObject.get("processName").value

          if (source.getName() != documentName) {
            // Build the new name for the document.
            def FullDocumentName = source.getSpaceName() + "." +
documentName;

            // Set the document title to the new name.
            source.setTitle(documentName)

            // Force the storage to keep the same version number, so that
this looks like a single save event
            source.setMetaDataDirty(false);
            source.setContentDirty(false);

            // Rename the document
            source.rename(FullDocumentName, crtContext);
            *response.sendRedirect($xwiki.getURL(FullDocumentName));*
          }
        }        
    }
}

// Register against the Observation Manager
def observation = Utils.getComponent(ObservationManager.class)
observation.removeListener("ProcessDocumentRenamer")
def listener = new ProcessDocumentRenamer(xwiki, xcontext)
observation.addListener(listener)
{{/groovy}}

Anyone have any idea why?



--
View this message in context: 
http://xwiki.475771.n2.nabble.com/Looking-for-help-with-groovy-tp7589782p7589798.html
Sent from the XWiki- Dev mailing list archive at Nabble.com.
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to