Re: accessing a spring bean methods from sitemap

2012-11-13 Thread Mansour Al Akeel
Thank you all for helping in this.
Thorsten,
I went with you suggestion and it worked great just like expected.


On Sun, Nov 11, 2012 at 3:24 PM, Robby Pelssers  wrote:
> Hi Mansour,
>
> I do know how to access spring beans from C2.2 flowscript if that is of any 
> help.
>
> Some sample code:
>
> function getTicket() {
> var authenticator = cocoon.getComponent("name_of_spring_bean"); //this is 
> how you can get hold of a spring bean
> }
>
> But the main question is .. what are you trying to accomplish. It's not very 
> clear to me yet.  What is the end goal you are trying to accomplish? Maybe 
> you can do it purely in xslt.. just saying.
>
> Robby
>
> -Original Message-
> From: Mansour Al Akeel [mailto:mansour.alak...@gmail.com]
> Sent: Saturday, November 10, 2012 6:38 PM
> To: users
> Subject: accessing a spring bean methods from sitemap
>
> 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.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org
> For additional commands, e-mail: users-h...@cocoon.apache.org
>
>
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org
> For additional commands, e-mail: users-h...@cocoon.apache.org
>

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



RE: accessing a spring bean methods from sitemap

2012-11-11 Thread Robby Pelssers
Hi Mansour,

I do know how to access spring beans from C2.2 flowscript if that is of any 
help.

Some sample code:

function getTicket() {
var authenticator = cocoon.getComponent("name_of_spring_bean"); //this is 
how you can get hold of a spring bean
}

But the main question is .. what are you trying to accomplish. It's not very 
clear to me yet.  What is the end goal you are trying to accomplish? Maybe you 
can do it purely in xslt.. just saying.

Robby

-Original Message-
From: Mansour Al Akeel [mailto:mansour.alak...@gmail.com] 
Sent: Saturday, November 10, 2012 6:38 PM
To: users
Subject: accessing a spring bean methods from sitemap

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.

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




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



Re: accessing a spring bean methods from sitemap

2012-11-11 Thread Javier Puerto
2012/11/10 Thorsten Scherler 

> Hi Mansour,
>
> Javier is on a flight to Zürich 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 = 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 outlines
> how to access one from spring.
>
> in your spring file you have to add the ns declaration and something like
> the following:
> 
> xmlns:util="http://www.**springframework.org/schema/**util
> "
>   xsi:schemaLocation="...
> http://www.springframework.**org/schema/util
> http://www.springframework.**org/schema/util/spring-util-2.**5.xsd
> "
>
>  name="org.apache.cocoon.**components.modules.input.**
> InputModule/collection"
> class="es.sadesi.module.input.**Collection">
> 
> 
>
> 
>   
>   
>   
>   
>   
>   
>   
>   
>   
>   
> 
>
> 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 =  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 = 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 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/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="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ò" 
>>> escribió:
>>>
>>>  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 o

Re: accessing a spring bean methods from sitemap

2012-11-10 Thread Thorsten Scherler

Hi Mansour,

Javier is on a flight to Zürich ATM but I know what code he is talking 
about.


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 outlines how to access one from spring.


in your spring file you have to add the ns declaration and something 
like the following:


xmlns:util="http://www.springframework.org/schema/util";
  xsi:schemaLocation="...
http://www.springframework.org/schema/util 
http://www.springframework.org/schema/util/spring-util-2.5.xsd";







  
  
  
  
  

  
  
  
  
  


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 =  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 = 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 
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/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.


   
.
"

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ò" 
escribió:


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ò

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


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


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




--
Thorsten Scherler 
codeBusters S.L. - web based systems


http://www.codebusters.es/


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



Re: accessing a spring bean methods from sitemap

2012-11-10 Thread Mansour Al Akeel
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.


  
.
"

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ò" 
> escribió:
>
>> 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ò
>>
>> ASF Member, Apache Cocoon PMC and Apache Syncope PPMC Member
>> http://people.apache.org/~ilgrosso/
>>
>>
>> -
>> To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org
>> For additional commands, e-mail: users-h...@cocoon.apache.org
>>
>

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



Re: accessing a spring bean methods from sitemap

2012-11-10 Thread Javier Puerto
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ò" 
escribió:

> 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ò
>
> ASF Member, Apache Cocoon PMC and Apache Syncope PPMC Member
> http://people.apache.org/~ilgrosso/
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org
> For additional commands, e-mail: users-h...@cocoon.apache.org
>
>


Re: accessing a spring bean methods from sitemap

2012-11-10 Thread Francesco Chicchiriccò
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ò

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


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