> /mmbase/edit/wizard/jsp/wizard.jsp?wizard=config/articles/arti
cles&templates
> =/editors&objectnumber=hoofdpagina
> 
> The problem is that in several XSL stylesheets, the 'referrerdir' 
> variable, derived from the 'referrer'
> parameter, is used to resolve several CSS stylesheet and JavaScript 
> locations. These are of course never found by using my 'referrerdir'.

The finalist editwizards xsl's use the referrerdir to resolve the javascript
and css files, but I might switch that to templatedir (templatedir uses the
referrerdir when template parameter is missing).

> How do I link to a wizard.jsp and provide the correct 'referrer'
> parameter to remain on the same wizard.jsp after clicking 'Save' or 
> 'Cancel'.

You could have a jsp as the referrer and redirect the browser back to your
url or you could hack the wizard.jsp.

I have 2 options for you when you hack the wizard.jsp.
For both options add this to the wizard.jsp

<%!
   /**
    * The mainwizard is the first wizard on the stack.
    *
    * @param ewconfig
    * @param wconfig the wizard configuration
    * @return <code>true</code> only if the wizard is the first one on the
stack
    */
   public boolean isMainWizard(Config ewconfig, Config.WizardConfig wconfig)
{
      Stack configs = ewconfig.subObjects;
      Iterator iter = configs.iterator();
      while (iter.hasNext()) {
         Object element = iter.next();
         if (element instanceof Config.WizardConfig) {
            return element == wconfig;
         }
      }
      return false;
   }
%>

OPTION 1
--------------
Replace

if (wizardConfig.wiz.mayBeClosed()) {
    log.trace("Closing this wizard");
    response.sendRedirect(response.encodeURL("wizard.jsp?sessionkey=" +
ewconfig.sessionKey +
                                             "&proceed=true" +
                                             "&remove=true" +
                                             "&popupid=" + popupId )); }

By

if (wizardConfig.wiz.mayBeClosed()) {
    if (isMainWizard(ewconfig, wizardConfig) {
    log.trace("Reloading this wizard");
    response.sendRedirect(response.encodeURL("wizard.jsp?sessionkey=" +
ewconfig.sessionKey +
                                             "&proceed=true" +
                                             "&popupid=" + popupId ));
    }
    else {

    log.trace("Closing this wizard");
    response.sendRedirect(response.encodeURL("wizard.jsp?sessionkey=" +
ewconfig.sessionKey +
                                             "&proceed=true" +
                                             "&remove=true" +
                                             "&popupid=" + popupId ));
    }
}

The "&remove=true" tells the wizard to remove the current wizard
configuration from the stack and proceed with the next configuration on the
stack. Now the last wizardconfiguration on the stack is not removed with the
result that the wizard is reloaded instead of redirecting to the referrer.


OPTION 2
---------------
Replace

else {
    log.trace("Send html back");
    wizardConfig.wiz.writeHtmlForm(out, wizardConfig.wizard); }

BY

 else {
    log.trace("Send html back");

    Hashtable stylesheetParams = new Hashtable();
    stylesheetParams.put("mainwizard", isMainWizard(ewconfig,
wizardConfig)+"");
    wizardConfig.wiz.writeHtmlForm(out, wizardConfig.wizard,
stylesheetParams); }

Then add to the wizard.xsl

<xsl:param name="mainwizard">false</xsl:param>

<xsl:template name="buttons">
   <table class="buttonscontent">
      <tr>
         <td>
            <xsl:if test="$mainwizard=&apos;false&apos;">
               <!-- cancel -->
               <xsl:call-template name="cancelbutton" />
            </xsl:if>
            <!-- saveonly  -->
            <xsl:call-template name="saveonlybutton" />
            <xsl:if test="$mainwizard=&apos;false&apos;">
               <!-- commit  -->
               <xsl:call-template name="savebutton" />
            </xsl:if>
         </td>
      </tr>
   </table>
</xsl:template>

I don't know if this actually works. Just Hacked the options into this
email.

Nico


Reply via email to