Re: Lenya 2.0 passing form request parameters to usecase

Gintare Ragaisiene <[email protected]>
Newsgroups gmane.comp.cms.lenya.user
Message-ID <[email protected]>
So, i found solution by my self is like this:

1) in InsertAsset.jx replace
             <input
                  i18n:attr="value"
                  type="submit"
                  value="insertAsset.insert${mode}"

onclick="org.apache.lenya.editors.handleFormSubmit('insertAsset');"
                />

with

               <jx:choose>
                    <jx:when
test="${usecase.getParameter('lenya.exitUsecase') != null}">
                        <input name="submit"
                          i18n:attr="value"
                          type="submit"
                          value="insertAsset.insert${mode}"
                        />
                    </jx:when>
                    <jx:otherwise>
                        <input
                          i18n:attr="value"
                          type="submit"
                          value="insertAsset.insert${mode}"

onclick="org.apache.lenya.editors.handleFormSubmit('insertAsset');"
                        />
                    </jx:otherwise>
                </jx:choose>

in order to go back to usecase passed in lenya.exitUsecase.

2) in InsertAsset.java overide methods:

public String getTargetURL(boolean success) {
        //System.out.println("this.getTargetURL");
        String url = getParameterAsString(EXIT_URI);
        if (url == null) {
            url = getParameterAsString(DEFAULT_TARGET_URL);
        }
        if (url == null) {
            url = getSourceURL();
        }
        return url + getExitQueryString();
    }

    protected void doCheckExecutionConditions(){
        System.out.println("doCheckExecutionConditions()");
    }
    protected void doExecute() throws Exception {
        System.out.println("doExecute()");
    }

    /**
     * Returns the query string to access the exit usecase of this usecase.
     * @return A query string of the form
     *
<code>?lenya.usecase=...&amp;param1=foo&amp;param2=bar</code>.
     */
    protected String getExitQueryString() {
        //System.out.println("InsertAsset getExitQueryString()
!!!!!!!!!!!!!!!!!!!");
        //System.out.println("InsertAsset this.getParameters() =
"+this.getParameters());
        StringBuffer queryBuffer = new StringBuffer();
        String exitUsecase = getParameterAsString("lenya.exitUsecase");
        if (exitUsecase != null && !"".equals(exitUsecase)) {
            queryBuffer.append("?lenya.usecase=").append(exitUsecase);
        }

        String url = getParameterAsString("url");
        if (url != null && !"".equals(url)) {
            queryBuffer.append("&url=").append(url);
        }

        String rowId = getParameterAsString("rowId");
        if (rowId != null && !"".equals(rowId)) {
            queryBuffer.append("&rowId=").append(rowId);
        }

        return queryBuffer.toString();
    }

parameters are appended to query in getExitQueryString().


That's it

Gintarė




On Mon, Jan 18, 2010 at 11:48 AM, Gintare Ragaisiene <
[email protected]> wrote:

> Hello,
>
>    I have usecase editors.insertImage that after image selection gets back
> to my implemented usecase ginactions.edit :
>
> <xconf xpath="/cocoon/usecases"
> unless="/cocoon/usecases/component-instance[@name = 'ginactions.edit']">
>   <component-instance name="ginactions.edit"
>                       logger="lenya.site.ginactions"
>
> class="com.ginsoftware.lenya.cms.ginactions.ActionsEdit">
>     <view
>        uri="modules/ginactions/usecases/dynamicrepeater_template.xml"
>        customFlow="fallback://lenya/modules/ginactions/flow/customFlow.js"
>     />
>     <event id="edit"/>
>   </component-instance>
> </xconf>
>
> where
>
> package com.ginsoftware.lenya.cms.ginactions;
> ...
> public class ActionsEdit extends InvokeWorkflow{
>  ...
> }
>
> In other words, I open my usecase ginactions.edit, click on link "Insert
> image" , go to usecase editors.insertImage, select image and go back to
> ginactions.edit with image request parameters from editors.insertImage POST
> form.
>
> How can I get those selected image parameters values with
> this.getParameterAsString("...") in ActionsEdit.java ?
>
> Thanks,
> Gintarė
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.