In the example in my last post I'm handling a Node which is a Text: I'm 
creating a new Text node under the same parent and I'm setting the content of 
the new node.

Now I would like to do the same for a Node which is an Element instead of a 
Text, but I can't seem to see a way to set the content of an Element node.

F.ex. I have an Element which is

<div>my text content</div>

I create a new Element with same name and attributes, and the new element ends 
up being

<div></div>

but I don't know how to set the text content in it. Can it be done ?


-----Original Message-----
From: Thiago H de Paula Figueiredo [mailto:thiag...@gmail.com] 
Sent: Thursday, July 10, 2014 19:36
To: Tapestry users
Subject: Re: FW: Customizing the grid to alter its own content

On Thu, 10 Jul 2014 11:55:57 -0300, Davide Vecchi <d...@amc.dk> wrote:

> As usual, thanks a lot for the great assistance, and in particular for 
> pointing me to DOM rewriting.
>
> List<Node> nodes = elementToModify.getChildren();
>
> if (nodes.size() == 1)
> {
>       if (nodes.get(0) instanceof Text)
>       {
>               Text currentNode = (Text) nodes.get(0);
>               
>               Text newNode = elementToModify.text("pippo " + 
> currentNode.toString());
>               
>               newNode.moveToTop(elementToModify);
>               
>               nodes = elementToModify.getChildren();
>               
>               nodes.get(1).remove();
>       }
> }

I think the code is ok, even if it could have some improvements.

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer http://machina.com.br

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

Reply via email to