Thanks Simon for your answer,

In fact this is what I want to do: accessing the data of a paragraph

The problem is that my code runs in a basic java application (not in a
container). So I don't have any access to the request and so to the
"hierarchieManager" that will allow me to access the content of my page. :-(

This the solution I use for accessing the data of a specific paragraph:
        Node rootNode = session.getRootNode();
        Node newsNode = rootNode.getNode("clio/news");
        Node paragraphNode = newsNode.getNode(PARAGRAPH_NAME);

        Iterator it = paragraphNode.getNodes();
        while (it.hasNext()) {
                Node n = (Node) it.next();
                try {
        
System.out.println(n.getProperty(PROPERTY_NAME).getValue()
                        .getString());
                } catch (javax.jcr.PathNotFoundException e) {
                        logger.logInfo("The path " + PROPERTY_NAME
                        + " does not exist for this node: " + n.getName()
                        + ", content will be ignored");
                }
        }

Thanks for your help




-----Message d'origine-----
De : [email protected] [mailto:[EMAIL PROTECTED] 
Envoyé : vendredi, 12. mai 2006 10:27
À : [email protected]
Objet : Re: [magnolia-user] Add some content to repository by programmation

Hi Benjamin,

I think maybe it's not entirely clear from your previous post what you
want to be able to do, hence why you haven't had any replies. If it's
to do with accessing paragraph content on a code and aggregating that
further up the node tree then this Wiki entry will be a good place to
start:
http://www.magnolia.info/wiki/Wiki.jsp?page=SimpleNewsAggregatorTemplate

Hope that helps. If not then can you post some more info on what you want to
do.

Simon

On 12/05/06, Benjamin Sempere <[email protected]> wrote:
> Is there any documentation where I can find a sample code that does this?
>
>
> -----Message d'origine-----
> De: [email protected] [mailto:[EMAIL PROTECTED]
> Envoyé: mercredi, 10. mai 2006 11:37
> À: [email protected]
> Objet: [magnolia-user] Add some content to repository by programmation
>
> Hi,
>
> I've a little question in glace with Magnolia (v2.5):
> In fact, I would like to add some content in the repository...
>
> *Here is my website structure:
>   MyWebsite
>      Department 1
>      Department 2
>      Department 2
>      Department 4 (template: "twoColumns")
>
> *I would like to add some content for the paragraph named
> "rightColumnParagraph" of the "twoColumns" template used by the
"Department
> 4" page.
> For the moment, I am only able to connect myself on the repository and to
> get a node (I do not know really if this last is the content node that I
am
> trying to find :-():
>       Hashtable<String, String> env = new Hashtable<String, String>();
>         env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
>         env.put(Context.PROVIDER_URL, providerURL);
>         InitialContext ctx = new InitialContext(env);
>
>         RegistryHelper.registerRepository(ctx, "myRep", configFile,
> repHomeDir, true);
>
>         // Obtain the repository through a JNDI lookup
>         Repository r = (Repository) ctx.lookup("myRep");
>
>         // Create a new repository session, after authenticating
>         Session session = r.login(new SimpleCredentials(login,
> password.toCharArray()), null);
>
>         Node rootNode = session.getRootNode();
>         Node contentNode =
> rootNode.getNode("clio/news/rightColumnParagraphs/MetaData/jcr:content");
>
> Can someone help me in order to complete this step (getting the right node
> and add some data like string to it)?
> Thx in advance,
>
>         Benjamin
>
>
>
> ----------------------------------------------------------------
> for list details see
> http://www.magnolia.info/en/magnolia/developer.html
> ----------------------------------------------------------------
>
>
> ----------------------------------------------------------------
> for list details see
> http://www.magnolia.info/en/magnolia/developer.html
> ----------------------------------------------------------------
>

----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/magnolia/developer.html
----------------------------------------------------------------


----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/magnolia/developer.html
----------------------------------------------------------------

Reply via email to