Hi,
I looked at your code -
it seems you try to render the same block recursivley. This will work only in really stateless components. I will assume the For component is not stateless - you can not recusivley render it from within the component itself because it will get "confused". Its similar to thread-saftyness - you can not use the same component from two threads, and you can not invoke the renderComponent method again from within the renderComponent.

Instead, use a component which iterates through your tree from java and renders its body for each node.

Cheers,
Ron





 Wouter De Vaal:
I've tried the For component and it has the same behaviour.

Anyone any idea's?

Wouter

On 9/9/05, Wouter De Vaal <[EMAIL PROTECTED]> wrote:

I'll try that.
A remark though: the apidoc doesn't show anything about Foreach being
deprecated.

Wouter

On 9/9/05, Ron Piterman <[EMAIL PROTECTED]> wrote:

Am not sure if it will solve your problem, but Foreach is deprecated.
Try using For instead, may be it will work...



 Wouter De Vaal:

Hi,

I have a strange problem with a foreach component within a block that
only gets called once, but the block renders multiple times. This code
worked in tapestry 3, but gives an overflow in tapestry 4 beta 6,
because the foreach source doesn't get reevaluated I think.

Regards,
Wouter

PS: I've created a skeleton test page/class to test it:

html:
<html>
<body>
   <comp jwcid="@RenderBlock" block="ognl:components.subMenuItems"/>
   <comp jwcid="[EMAIL PROTECTED]">
       Blah:<br/>
       <comp jwcid="@Foreach" source="ognl:menuItems" value="ognl:menuItem">
           <comp jwcid="@Insert" value="ognl:menuName"/><br/>
           <comp jwcid="@Conditional" condition="ognl:hasAvailableSubItems">
               <comp jwcid="@Insert" value="ognl:test"/>
               <comp jwcid="@RenderBlock"
block="ognl:components.subMenuItems"/>
           </comp>
       </comp>
     </comp>
</body>
</html>

Page file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE page-specification PUBLIC
 "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
 "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd";>
<page-specification class="EditMenuItemTest">

</page-specification>

Java class:
import java.util.ArrayList;
import java.util.List;

import org.apache.tapestry.event.PageBeginRenderListener;
import org.apache.tapestry.event.PageEvent;
import org.apache.tapestry.html.BasePage;

public abstract class EditMenuItemTest extends BasePage implements
       PageBeginRenderListener {

   public class MenuItem {

       private String name;
       private List<MenuItem> subItems = new ArrayList<MenuItem>();

       public MenuItem(String name) {
           this.name = name;
       }

       public List<MenuItem> getSubItems() {
           return subItems;
       }

       public void setSubItems(List<MenuItem> subItems) {
           this.subItems = subItems;
       }

       public String getName() {
           return name;
       }

       @Override
       public String toString() {
           return name;
       }

   }

   public void pageBeginRender(PageEvent evt) {
       // create some menu items
       MenuItem root = new MenuItem("root");
       MenuItem a = new MenuItem("a");
       MenuItem b = new MenuItem("b");
       MenuItem c = new MenuItem("c");
       MenuItem aa = new MenuItem("aa");
       MenuItem ab = new MenuItem("ab");
       MenuItem ac = new MenuItem("ac");
       MenuItem aba = new MenuItem("aba");
       MenuItem abb = new MenuItem("abb");
       root.getSubItems().add(a);
       root.getSubItems().add(b);
       root.getSubItems().add(c);
       c.getSubItems().add(aa);
       c.getSubItems().add(ab);
       c.getSubItems().add(ac);
       ab.getSubItems().add(aba);
       ab.getSubItems().add(abb);
       setRootMenuItem(root);
   }

   public abstract MenuItem getRootMenuItem();

   public abstract void setRootMenuItem(MenuItem root);

   public abstract MenuItem getMenuItem();

   public List<MenuItem> getMenuItems() {
       if (getMenuItem() == null) {
           System.out.println("get menu items with null called,
returning: " + getRootMenuItem().getSubItems());
           return getRootMenuItem().getSubItems();
       } else {
           System.out.println("get menu items called, returning: " +
getMenuItem().getSubItems());
           return getMenuItem().getSubItems();
       }
   }

   public String getMenuName() {
       System.out.println("get menu name called, current menu item: "
               + getMenuItem());
       return getMenuItem().getName();
   }

   public String getTest() {
       System.out.println("test called, current menu item: " + getMenuItem());
       return "";
   }

   public boolean isHasAvailableSubItems() {
       System.out.println("available:" + getMenuItem().getSubItems());
       return (getMenuItem().getSubItems().size() > 0);
   }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to