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:
<!--ns-->
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"
<bean id="collection"
name="org.apache.cocoon.components.modules.input.InputModule/collection"
class="es.sadesi.module.input.Collection">
<property name="map" ref="sections"/>
</bean>
<util:map id="sections" map-class="java.util.HashMap">
<entry key="0" value="0. Disposiciones estatales" />
<entry key="1" value="1. Disposiciones generales" />
<entry key="2" value="2. Autoridades y personal" />
<entry key="2.1" value="2.1. Nombramientos, situaciones e incidencias" />
<entry key="2.2" value="2.2. Oposiciones, concursos y otras
convocatorias" />
<entry key="3" value="3. Otras disposiciones" />
<entry key="4" value="4. Administración de justicia" />
<entry key="5" value="5. Anuncios" />
<entry key="5.1" value="5.1. Licitaciones públicas y adjudicaciones" />
<entry key="5.2" value="5.2. Otros anuncios oficiales" />
</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.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.
<input-modules>
<component-instance name="request"
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 <jpue...@gmail.com> 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ò" <ilgro...@apache.org>
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<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ò
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 <scherler.at.gmail.com>
codeBusters S.L. - web based systems
<consulting, training and solutions>
http://www.codebusters.es/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org
For additional commands, e-mail: users-h...@cocoon.apache.org