Re: How to implement nested components?

2011-03-30 Thread leon
Thanks for your reply!
Actually, I want to know how to implement nested components. I will show you
my scenario:

1. Requirment: A wizard that include some step to guide users complete a
task, e.g. a sale order
2. Current Implementation: I implemented two components Wizard and
WizardStep, and use them like this:
t:wizard steps=[step1,step2,step3]
  t:wizardStep name=step1
step1 content
  /t:wizardStep
  t:wizardStep name=step2
step2 content
  /t:wizardStep
  t:wizardStep name=step3
step3 content
  /t:wizardStep
/t:wizard

// wizard class
@Property
private WizardStep[] steps;

in this way, I need to pass WizardSteps as Property. But I want to use them
as follows:
t:wizard
  t:wizardStep name=step1
step1 content
  /t:wizardStep
  t:wizardStep name=step2
step2 content
  /t:wizardStep
  t:wizardStep name=step3
step3 content
  /t:wizardStep
/t:wizard

//wizard class
@Inject
private ComponentResources resources;
private WizardStep[] steps;
@SetupRender
private viod setupRender(){
  //initialize steps by iterate child components
  steps = initSteps();
}
//I want to use ComponentResources to get WizardSteps ids then use
getEmbeddedComponent() to get WizardStep instance.
private void initSteps() {
  ListString stepIds =
resources.getComponentModel().getEmbeddedComponentIds();
  //Why stepIds is empy! so the follows codes will never execute!
  steps = new WizardStep[stepIds.size())];
  int i = 0;
  for (String stepId: stepIds){
steps[i++] = resources.getEmbeddedComponent(stepId);
  }
}

I am really confused, what's wrong with my second implementing?
Any suggestion? Thanks!

On Wed, Mar 23, 2011 at 8:17 PM, Thiago H. de Paula Figueiredo 
thiag...@gmail.com wrote:

 On Tue, 22 Mar 2011 22:56:28 -0300, leon mail@gmail.com wrote:

  Sorry, My question is :are there some documentations about nested
 components?


 All components are nested, so I don't know what you're asking. A non-page
 component instance doesn't exist outside a page, which is almost the same as
 a component, so all components are nested.


  I tried to inspect the component in debug model, but they're all null
 objects, I'm using IDEA 10, I don't know if is caused by IDE or Tapestry
 IoC.


 This is not caused by the IDE or Tapestry-IoC, but by Tapestry(-core)
 itself. It was already solved for 5.3-SNAPSHOT.


  So how could i trace a component's lifecycle?


 See this: http://tapestry.apache.org/component-rendering.html.


 --
 Thiago H. de Paula Figueiredo
 Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
 and instructor
 Owner, Ars Machina Tecnologia da Informação Ltda.
 http://www.arsmachina.com.br




-- 
Best Regards
Li Guoqiang


Re: How to implement nested components?

2011-03-23 Thread Thiago H. de Paula Figueiredo

On Tue, 22 Mar 2011 22:56:28 -0300, leon mail@gmail.com wrote:


Sorry, My question is :are there some documentations about nested
components?


All components are nested, so I don't know what you're asking. A non-page  
component instance doesn't exist outside a page, which is almost the same  
as a component, so all components are nested.



I tried to inspect the component in debug model, but they're all null
objects, I'm using IDEA 10, I don't know if is caused by IDE or Tapestry
IoC.


This is not caused by the IDE or Tapestry-IoC, but by Tapestry(-core)  
itself. It was already solved for 5.3-SNAPSHOT.



So how could i trace a component's lifecycle?


See this: http://tapestry.apache.org/component-rendering.html.

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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



Re: How to implement nested components?

2011-03-22 Thread leon
Sorry, My question is :are there some documentations about nested
components?
I tried to inspect the component in debug model, but they're all null
objects, I'm using IDEA 10, I don't know if is caused by IDE or Tapestry
IoC.
So how could i trace a component's lifecycle?

On Mon, Mar 21, 2011 at 8:41 PM, Thiago H. de Paula Figueiredo 
thiag...@gmail.com wrote:

 On Sun, 20 Mar 2011 22:50:20 -0300, leon mail@gmail.com wrote:

  Thanks a lot, I will try it, I looks Tapestry's component's relationship
 is build by component class rather than component template.


 Wrong. It's defined by template. Using @InjectComponent or
 getEmbeddedComponent() is just a way of getting the nested component
 instance.


  So, are there some dos about this?


 Could you rephrase your question?


 --
 Thiago H. de Paula Figueiredo
 Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
 and instructor
 Owner, Ars Machina Tecnologia da Informação Ltda.
 http://www.arsmachina.com.br




-- 
Best Regards
Li Guoqiang


Re: How to implement nested components?

2011-03-22 Thread Taha Hafeez
It will help if you share the code with us

regards
Taha


On Wed, Mar 23, 2011 at 7:26 AM, leon mail@gmail.com wrote:

 Sorry, My question is :are there some documentations about nested
 components?
 I tried to inspect the component in debug model, but they're all null
 objects, I'm using IDEA 10, I don't know if is caused by IDE or Tapestry
 IoC.
 So how could i trace a component's lifecycle?

 On Mon, Mar 21, 2011 at 8:41 PM, Thiago H. de Paula Figueiredo 
 thiag...@gmail.com wrote:

  On Sun, 20 Mar 2011 22:50:20 -0300, leon mail@gmail.com wrote:
 
   Thanks a lot, I will try it, I looks Tapestry's component's relationship
  is build by component class rather than component template.
 
 
  Wrong. It's defined by template. Using @InjectComponent or
  getEmbeddedComponent() is just a way of getting the nested component
  instance.
 
 
   So, are there some dos about this?
 
 
  Could you rephrase your question?
 
 
  --
  Thiago H. de Paula Figueiredo
  Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
  and instructor
  Owner, Ars Machina Tecnologia da Informação Ltda.
  http://www.arsmachina.com.br
 



 --
 Best Regards
 Li Guoqiang



Re: How to implement nested components?

2011-03-21 Thread Thiago H. de Paula Figueiredo

On Sun, 20 Mar 2011 22:50:20 -0300, leon mail@gmail.com wrote:

Thanks a lot, I will try it, I looks Tapestry's component's relationship  
is build by component class rather than component template.


Wrong. It's defined by template. Using @InjectComponent or  
getEmbeddedComponent() is just a way of getting the nested component  
instance.



So, are there some dos about this?


Could you rephrase your question?

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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



Re: How to implement nested components?

2011-03-20 Thread leon
Thanks a lot, I will try it, I looks Tapestry's component's relationship is
build by component class rather than component template.
So, are there some dos about this?

On Sat, Mar 19, 2011 at 9:37 PM, Thiago H. de Paula Figueiredo 
thiag...@gmail.com wrote:

 On Sat, 19 Mar 2011 01:16:21 -0300, Taha Hafeez tawus.tapes...@gmail.com
 wrote:

  resources.getContainerResources().getEmbeddedComponent(nested_component_id);


 Also this:

 @InjectComponent
 private ComB comB; // the name of the field should be the same as the
 component's t:id

 or

 @InjectComponent(componentId)
 private ComB anyFieldname;

 --
 Thiago H. de Paula Figueiredo
 Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
 and instructor
 Owner, Ars Machina Tecnologia da Informação Ltda.
 http://www.arsmachina.com.br

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




-- 
Best Regards
Li Guoqiang


Re: How to implement nested components?

2011-03-19 Thread Thiago H. de Paula Figueiredo
On Sat, 19 Mar 2011 01:16:21 -0300, Taha Hafeez tawus.tapes...@gmail.com  
wrote:



 resources.getContainerResources().getEmbeddedComponent(nested_component_id);


Also this:

@InjectComponent
private ComB comB; // the name of the field should be the same as the  
component's t:id


or

@InjectComponent(componentId)
private ComB anyFieldname;

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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



Re: How to implement nested components?

2011-03-18 Thread Taha Hafeez
Hi

AFAIK, the nested components(comB) can be accessed from the container's
ComponentResources not the component's(comA) and the nested components(comB)
are present in the container not the component(comA)... So you need to know
the nested component's id to access it which can be passed as a parameter to
the component(comA)

Try

 resources.getContainerResources().getEmbeddedComponent(nested_component_id);

regards
Taha

On Sat, Mar 19, 2011 at 7:44 AM, leon mail@gmail.com wrote:

 Hi all,
 I have a requirement to implement nested components, it like this:
 t:comA
   t:comB/
   t:comB/
   t:comB/
 /t:comA

 I have created components, but I can't access embedded components in comA:
 public class comA {
  @Inject
  private ComponentResources resources;

  void setupRender() {
ComponentModel model = resources.getComponentModel();
ListString embeddedIds = model.getEmbeddedIds();
// The problem is that embeddedIds.size() is 0!
  }
 }

 So, Is this a wrong way? I'm so confused.
 Any idea? thanks!
 --
 Best Regards
 Li Guoqiang