Return-Path: X-Original-To: apmail-cocoon-users-archive@www.apache.org Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5DC8BD345 for ; Sun, 11 Nov 2012 12:27:23 +0000 (UTC) Received: (qmail 72892 invoked by uid 500); 11 Nov 2012 12:27:22 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 72259 invoked by uid 500); 11 Nov 2012 12:27:17 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: users@cocoon.apache.org List-Id: Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 72201 invoked by uid 99); 11 Nov 2012 12:27:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Nov 2012 12:27:15 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jpuerto@gmail.com designates 209.85.217.179 as permitted sender) Received: from [209.85.217.179] (HELO mail-lb0-f179.google.com) (209.85.217.179) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Nov 2012 12:27:10 +0000 Received: by mail-lb0-f179.google.com with SMTP id c1so3808722lbg.24 for ; Sun, 11 Nov 2012 04:26:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=SqsJc5iz+Zpz1Oxl/EWI5P9WCv+0SU7bRDhfkqyO7jo=; b=XZEsfoqP/CZzVJS9/ROSvlZQastnvp68sIE5NC2xgdI8MRixk+1Vudf3L9+ja06mP3 ScP/AXZNstnLDTgN5TThdIZb5jeepaVY3XYUvBYpSszIt7DJEMwRNLJp7AD0TpoPZvUI Kba1SCj5edCr9+63avq/OXEo8s/309Xggt9hABC2hR8RpsQeYdEeweweGi8etqPcU5gT 0F2GVSeAwcBt/w7SC9GYCwcmu4dus4nlAqP9Qe1lU4UyBuhH8vdZnqQaS0yARM6rXBXa LvybYTH0++/rW3O3nbAgOpncjwd5PfsEKdUrkONUYpGHnZaJYCRUd+R17jFLF0/+fVRj xc7w== MIME-Version: 1.0 Received: by 10.152.105.236 with SMTP id gp12mr15467421lab.35.1352636808815; Sun, 11 Nov 2012 04:26:48 -0800 (PST) Received: by 10.112.36.195 with HTTP; Sun, 11 Nov 2012 04:26:48 -0800 (PST) In-Reply-To: <509ED4D2.4020306@gmail.com> References: <509E91BD.6010300@apache.org> <509ED4D2.4020306@gmail.com> Date: Sun, 11 Nov 2012 13:26:48 +0100 Message-ID: Subject: Re: accessing a spring bean methods from sitemap From: Javier Puerto To: users@cocoon.apache.org Content-Type: multipart/alternative; boundary=f46d0407144b7fe26104ce374c69 X-Virus-Checked: Checked by ClamAV on apache.org --f46d0407144b7fe26104ce374c69 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 2012/11/10 Thorsten Scherler > Hi Mansour, > > Javier is on a flight to Z=FCrich ATM but I know what code he is talking > about. > Yeah, for an input module. If you want to access from a flowscript as Francesco suggested you can use this: var yourComponentInstance =3D cocoon.getComponent("BEAN-ID"); > > I read between the lines that you are on 2.2. If you happen to be on 3 > then the whole thing is much straight forward. > > I am not sure whether the following is the best approach for your problem > since it depends on where you want to come the hashMap from. Next outline= s > how to access one from spring. > > in your spring file you have to add the ns declaration and something like > the following: > > xmlns:util=3D"http://www.**springframework.org/schema/**util > " > xsi:schemaLocation=3D"... > http://www.springframework.**org/schema/util > http://www.springframework.**org/schema/util/spring-util-2.**5.xsd > " > > name=3D"org.apache.cocoon.**components.modules.input.** > InputModule/collection" > class=3D"es.sadesi.module.input.**Collection"> > > > > > > > > > convocatorias" /> > > > > > > > > Then create a es.sadesi.module.input.**Collection class with something > like > package es.sadesi.module.input; > > import java.util.Map; > > import org.apache.avalon.framework.**configuration.Configuration; > import org.apache.avalon.framework.**configuration.** > ConfigurationException; > import org.apache.cocoon.components.**modules.input.**AbstractInputModule= ; > import org.apache.cocoon.components.**modules.input.InputModule; > import org.springframework.beans.**factory.annotation.Required; > > public class Collection extends AbstractInputModule { > private InputModule map; > > public Object getAttribute(String name, Configuration modeConf, > Map objectModel) throws ConfigurationException { > > final Object result =3D map.getAttribute(name, null, null); > return result; > > } > > public Object getAttribute(String name) throws ConfigurationException= { > return getAttribute(name, null, null); > } > > @Required > public void setMap(InputModule map) { > this.map =3D map; > } > } > > then use it in your sitemap with > {collection:2.2} which should return "2.2. Oposiciones, concursos y otras > convocatorias" > > That should work in 2.2 (I have no time to test it so it may miss > something in the extraction of the customer use case but it should get yo= u > started). > > HTH > > salu2 > > > On 11/10/2012 08:07 PM, Mansour Al Akeel wrote: > >> Javier, >> thank you. >> The module I am going to implement is to be used by one block only, >> and would love to be able to declare it in the sitemap.xmap. >> I haven't implemented input modules before, but reading this: >> >> http://cocoon.apache.org/2.1/**userdocs/concepts/modules.html >> >> >> "Step 1: Making a new module known to Apache Cocoon >> >> Like other core components of Apache Cocoon, modules are declared in >> cocoon.xconf. There are already too many to list here. >> >> >> > class=3D"org.apache.cocoon.**components.modules.input.** >> RequestParameterModule"/> >> ..... >> " >> >> since I am developing with maven and jetty, and doing it in on block, >> I like to declare this new input module in the sitemap.xmap or in the >> same block (jar). >> >> Is there a way to do this ?? >> >> >> >> >> On Sat, Nov 10, 2012 at 1:09 PM, Javier Puerto wrote= : >> >>> I did something similar for a client. We did it with a custom input >>> module >>> so you can define a protocol on when the input is the key an the output >>> the >>> value. >>> >>> Also I can't access to my laptop now but I have an example about >>> accessing >>> to spring beans from flow script, probably the input module it's enough= . >>> >>> Salu2 >>> >>> El 10/11/2012 18:41, "Francesco Chicchiricc=F2" >>> escribi=F3: >>> >>> On 10/11/2012 18:38, Mansour Al Akeel wrote: >>>> >>>>> I need to link documents through some identification. For example, >>>>> assuming that I have: >>>>> >>>>> articles/my-first-article.xml >>>>> articles/second-one.xml >>>>> articles/hello-world-article.**xml >>>>> >>>>> books/book1.xml which has references to artice-1 and article-3 >>>>> identified by an id of the form: A001 >>>>> >>>>> I need to create a hashtable linking both so that I pass query param >>>>> by ID or by name. The idea I have is to initialize spring bean that >>>>> will extract the data from these files, >>>>> and construct a Map. >>>>> >>>>> My question is how can I access this HashTable from sitemap ?? >>>>> >>>>> I am using C2.2. >>>>> >>>> Hi, >>>> I don't think there is any direct way to access an Hashtable from the >>>> sitemap: maybe the only chance is to get to it through flowscript... >>>> >>>> Don't have idea of how to access a Spring bean from flowscript, >>>> though... any C2.2. expert around? >>>> >>>> Regards. >>>> >>>> -- >>>> Francesco Chicchiricc=F2 >>>> >>>> ASF Member, Apache Cocoon PMC and Apache Syncope PPMC Member >>>> http://people.apache.org/~**ilgrosso/ >>>> >>>> >>>> ------------------------------**------------------------------** >>>> --------- >>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.**apache.org >>>> For additional commands, e-mail: users-help@cocoon.apache.org >>>> >>>> ------------------------------**------------------------------** >> --------- >> To unsubscribe, e-mail: users-unsubscribe@cocoon.**apache.org >> For additional commands, e-mail: users-help@cocoon.apache.org >> >> > > -- > Thorsten Scherler > codeBusters S.L. - web based systems > > > http://www.codebusters.es/ > > > > ------------------------------**------------------------------**--------- > To unsubscribe, e-mail: users-unsubscribe@cocoon.**apache.org > For additional commands, e-mail: users-help@cocoon.apache.org > > --f46d0407144b7fe26104ce374c69 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

2012/11/10 Thorsten Scherler <scherl= er@gmail.com>
Hi Mansour,

Javier is on a flight to Z=FCrich ATM but I know what code he is talking ab= out.

Yeah, for an input module. If you want to acc= ess from a flowscript as Francesco suggested you can use this:

var y= ourComponentInstance =3D cocoon.getComponent("BEAN-ID");
=A0

I read between the lines that you are on 2.2. If you happen to be on 3 then= the whole thing is much straight forward.

I am not sure whether the following is the best approach for your problem s= ince it depends on where you want to come the hashMap from. Next outlines h= ow to access one from spring.

in your spring file you have to add the ns declaration and something like t= he following:
<!--ns-->
xmlns:util=3D"http://www.springframework.org/schema/util"
=A0 xsi:schemaLocation=3D"...
ht= tp://www.springframework.org/schema/util http:= //www.springframework.org/schema/util/spring-util-2.5.xsd= "

<bean id=3D"collection"
name=3D"org.apache.cocoon.components.modules.input.Input= Module/collection"
=A0 =A0 class=3D"es.sadesi.module.input.Collection"> =A0 =A0 <property name=3D"map" ref=3D"sections"/>=
</bean>

<util:map id=3D"sections" map-class=3D"java.util.HashMap&= quot;>
=A0 <entry key=3D"0" value=3D"0. Disposiciones estatales&= quot; />
=A0 <entry key=3D"1" value=3D"1. Disposiciones generales&= quot; />
=A0 <entry key=3D"2" value=3D"2. Autoridades y personal&q= uot; />
=A0 <entry key=3D"2.1" value=3D"2.1. Nombramientos, situa= ciones e incidencias" />
=A0 <entry key=3D"2.2" value=3D"2.2. Oposiciones, concurs= os y otras convocatorias" />
=A0 <entry key=3D"3" value=3D"3. Otras disposiciones"= ; />
=A0 <entry key=3D"4" value=3D"4. Administraci=F3n de just= icia" />
=A0 <entry key=3D"5" value=3D"5. Anuncios" />
=A0 <entry key=3D"5.1" value=3D"5.1. Licitaciones p=FAbli= cas y adjudicaciones" />
=A0 <entry key=3D"5.2" value=3D"5.2. Otros anuncios ofici= ales" />
</util:map>

Then create a es.sadesi.module.input.Collection class with something= like
package es.sadesi.module.input;

import java.util.Map;

import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.Configuratio= nException;
import org.apache.cocoon.components.modules.input.AbstractInp= utModule;
import org.apache.cocoon.components.modules.input.InputModule;
import org.springframework.beans.factory.annotation.Required;

public class Collection extends AbstractInputModule {
=A0 =A0 private InputModule map;

=A0 =A0 public Object getAttribute(String name, Configuration modeConf,
=A0 =A0 =A0 =A0 =A0 =A0 Map objectModel) throws ConfigurationException {
=A0 =A0 =A0 =A0 final Object result =3D =A0map.getAttribute(name, null, nul= l);
=A0 =A0 =A0 =A0 return result;

=A0 =A0 }

=A0 =A0 public Object getAttribute(String name) throws ConfigurationExcepti= on {
=A0 =A0 =A0 return getAttribute(name, null, null);
=A0 =A0 }

=A0 =A0 @Required
=A0 =A0 public void setMap(InputModule map) {
=A0 =A0 =A0 =A0 this.map =3D map;
=A0 =A0 }
}

then use it in your sitemap with
{collection:2.2} which should return "2.2. Oposiciones, concursos y ot= ras convocatorias"

That should work in 2.2 (I have no time to test it so it may miss something= in the extraction of the customer use case but it should get you started).=

HTH

salu2


On 11/10/2012 08:07 PM, Mansour Al Akeel wrote:
Javier,
thank you.
The module I am going to implement is to be used by one block only,
and would love to be able to declare it in the sitemap.xmap.
I haven't implemented input modules before, but reading this:

http://cocoon.apache.org/2.1/userdocs/concepts/module= s.html


"Step 1: Making a new module known to Apache Cocoon

Like other core components of Apache Cocoon, modules are declared in
cocoon.xconf. There are already too many to list here.

<input-modules>
=A0 =A0<component-instance name=3D"request"
=A0 =A0class=3D"org.apache.cocoon.components.modules.input.<= /u>RequestParameterModule"/>
.....
"

since I am developing with maven and jetty, and doing it in on block,
I like to declare this new input module in the sitemap.xmap or in the
same block (jar).

Is there a way to do this ??




On Sat, Nov 10, 2012 at 1:09 PM, Javier Puerto <jpuerto@gmail.com> wrote:
I did something similar for a client. We did it with a custom input module<= br> so you can define a protocol on when the input is the key an the output the=
value.

Also I can't access to my laptop now but I have an example about access= ing
to spring beans from flow script, probably the input module it's enough= .

Salu2

El 10/11/2012 18:41, "Francesco Chicchiricc=F2" <ilgrosso@apache.org>
escribi=F3:

On 10/11/2012 18:38, Mansour Al Akeel wrote:
I need to link documents through some identification. For example,
assuming that I have:

articles/my-first-article.xml
articles/second-one.xml
articles/hello-world-article.xml

books/book1.xml =A0which has =A0references to =A0artice-1 and article-3
identified by an id of the form: A001

I need to create a hashtable linking both so that I pass query param
by ID or by name. The idea I have is to initialize spring bean that
will extract the data from these files,
and construct a Map<String,String>.

My question is how can I access this HashTable from sitemap ??

I am using C2.2.
Hi,
I don't think there is any direct way to access an Hashtable from the sitemap: maybe the only chance is to get to it through flowscript...

Don't have idea of how to access a Spring bean from flowscript,
though... any C2.2. expert around?

Regards.

--
Francesco Chicchiricc=F2

ASF Member, Apache Cocoon PMC and Apache Syncope PPMC Member
http://pe= ople.apache.org/~ilgrosso/


-------------------------------------------------------------= --------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org

-------------------------------------------------------------= --------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org



--
Thorsten Scherler <scherler.at.gmail.com>
codeBusters S.L. - web based systems
<consulting, training and solutions>

http://www.codebus= ters.es/



-------------------------------------------------------------= --------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


--f46d0407144b7fe26104ce374c69--