You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by Gintare Ragaisiene <gi...@gmail.com> on 2010/01/18 10:48:34 UTC

Lenya 2.0 passing form request parameters to usecase

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ė

Re: Lenya 2.0 passing form request parameters to usecase

Posted by Thorsten Scherler <th...@juntadeandalucia.es>.
On Tue, 2010-01-19 at 13:12 +0200, Gintare Ragaisiene wrote:
> So, i found solution by my self is like this:
...
> 
> That's it

Thanks for posting the solution.

salu2
-- 
Thorsten Scherler <thorsten.at.apache.org>
Open Source Java <consulting, training and solutions>

Sociedad Andaluza para el Desarrollo de la Sociedad 
de la Información, S.A.U. (SADESI)





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: Lenya 2.0 passing form request parameters to usecase

Posted by Gintare Ragaisiene <gi...@gmail.com>.
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 <
gintare.ragaisiene@gmail.com> 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ė
>
>
>