Todd Orr wrote:
[...] This is where I
found Environment to be deficient. It seems that no matter what
combination of phases of rendering I use I cannot get the data back to
the tabnavigation before it is finished rendering and therefore cannot
alter it's display.
Not sure that it matches what you want to do, but you could make your tabpanel register themselves to an environment value init ialized in tabgoup and read this env value in tabnavigation. Something like that :
(Sorry for the long post, I put all the code)

======================================

The enclosing element, for my test its a page (your tabgroup)
8<--------------------------------------------------------------------------------------------------
TestRegister.html
8<-------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> <html xmlns="http://www.w3.org/1999/xhtml"; xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
   <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
       <title>Register and print ids</title>
   </head>
   <body>

       <t:printregistered/>
       <t:registerid t:id="foo"/>
       <t:registerid t:id="bar"/>
       <t:registerid/>
       <t:printregistered/>
</body>
</html>
8<--------------------------------------------------------------------------------------------------
If you call contexturl/testregister, you see :
8<--------------------------------------------------------------------------------------------------

No id registered in env

I'm "foo" and should be registered.

I'm "bar" and should be registered.

I'm "registerid" and should be registered.

Found these ids in env:

   * Found: foo
   * Found: bar
   * Found: registerid

8<--------------------------------------------------------------------------------------------------

======================================
======================================
Now, the details :

TestRegister.java
8<-------------------------
public class TestRegister {
   @Inject
   private Environment environment;
   private Register register;
   private String id;
public String getId() {
       return this.id;
   }

   public void setId(String id) {
       this.id = id;
   }

   @SetupRender
   void initEnv() {
       register = new Register();
       environment.push(Register.class, register);
   }
@CleanupRender
   void cleanup() {
       environment.pop(Register.class);
   }
public List<String> getIds() {
       return this.register.getRegistered();
   }
}
8<-------------------------

The register object is really just here as a data container:
8<--------------------------------------------------------------------------------------------------
Register.jeva
8<------------------------
public class Register {
   private List<String> registered;
public Register() {
       registered = new ArrayList<String>();
   }
public void register(String id) {
       this.registered.add(id);
   }
public List<String> getRegistered() {
       return this.registered;
   }
}
8<--------------------------------------------------------------------------------------------------


Component that need to register themselves (your tabpanels) :
8<--------------------------------------------------------------------------------------------------
RegisterId.java :
8<------------------------
public class RegisterId {
   @Environmental
   private Register register;

   @Inject
   private ComponentResources resources;
@SetupRender
   void setup() {
       if(register != null) {
           this.register.register(resources.getId());
       }
   }
public String getId() {
       return resources.getId();
   }
}
8<------------------------
RegisterId.html
8<-------------------------
<p xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
   <t:if test="id">
       I'm "${id}" and should be registered.
       <t:parameter name="else">
           I have no id and sould not be registered.
       </t:parameter>
   </t:if>
</p>
8<--------------------------------------------------------------------------------------------------

======================================

The component that need to read registered ids (your tabnavigation)
8<--------------------------------------------------------------------------------------------------
PrintRegistered.java
8<-------------------------
public class PrintRegistered {

   @Environmental
   private Register register;
private String id; public List<String> getIds() {
       return null == register ? null : register.getRegistered();
   }

   public String getId() {
       return this.id;
   }

   public void setId(String id) {
       this.id = id;
   }
}
8<-------------------------
PrintRegistered.html
8<-------------------------
<div  xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
   <t:if test="ids">
       <p>Found these ids in env:</p>
       <ul>
       <t:loop source="ids" value="id">
           <li>Found: ${id}</li>
       </t:loop>
       </ul>
       <t:parameter name="else">
       <p>No id registered in env</p>
       </t:parameter>
   </t:if>
</div>
8<--------------------------------------------------------------------------------------------------

======================================

Several details need to be investigate : why the first <t:printregistered/> is empty (something to do with the render phase order), and if you want to only have declared id, perhaps use client in place of component id. But I think that it roughly mathc what you want to do.

Hope it may help !

--
Francois Armand
Etudes & Développements J2EE
LINAGORA SA - http://www.linagora.com
Tél.: +33 (0)1 58 18 68 28
-----------
InterLDAP - http://interldap.org FederID - http://www.federid.org/
Open Source identities management and federation


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

Reply via email to