RE: Is there a way to search component by its wicket ID ?

2012-08-13 Thread Paul Bors
In my unit test code I use:

  
com.googlecode.londonwicket
wicket-component-expressions
0.2.0
test

  
org.apache.wicket
wicket
  

  

Or see:
http://code.google.com/p/londonwicket/source/browse/repo/com/googlecode/lond
onwicket/wicket-component-expressions/?r=61#wicket-component-expressions%2F0
.2.0

They are a group of Wicket users from London and their two static method
tool allows you to use regexp in the component path as well as filtering by
a component type such as a TextBox and its model such as
Model("Hello World").

I don't think the new version of Wicket has this flexibility build in
WicketTester, but looking over the code of
BaseWicketTester#getComponentFromLastRenderedPage() and
BaseWicketTester#debugComponentTrees() you can implement your own method to
iterate through the component tree and return a reference to the component
you want.

~ Thank you,
  Paul Bors

-Original Message-
From: arkadyz111 [mailto:azelek...@gmail.com] 
Sent: Monday, August 13, 2012 9:41 AM
To: users@wicket.apache.org
Subject: Is there a way to search component by its wicket ID ?

Hello, team.

I am looking for a way to locate component by its wicket id in markup
container. But I see only option to search by "path" is supported.

Do I miss something ?

Thank you.



--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/Is-there-a-way-to-search-componen
t-by-its-wicket-ID-tp4651175.html
Sent from the Users forum mailing list archive at Nabble.com.

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



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



Re: Is there a way to search component by its wicket ID ?

2012-08-13 Thread James Eliyezar
You can definitely search by wicket id but you may have to specify the
hierarchy as well.
Something like this,

TextField usernameField = (TextField) get("userForm:username");
>

to get the text field component with the wicket id "username" inside the
form whose wicket id is "userForm".

Hope this helps you.

DISCLAIMER: I'm no wicket expert but these are my humble opinions and this
is what I do to locate components when they are loosely coupled.

On Mon, Aug 13, 2012 at 9:41 PM, arkadyz111  wrote:

> Hello, team.
>
> I am looking for a way to locate component by its wicket id in markup
> container. But I see only option to search by "path" is supported.
>
> Do I miss something ?
>
> Thank you.
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Is-there-a-way-to-search-component-by-its-wicket-ID-tp4651175.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Thanks & regards
James Selvakumar
mcruncher.com


Re: Is there a way to search component by its wicket ID ?

2012-08-14 Thread arkadyz111
But why we have to write "userForm" ? What is an idea behind of this ?

Why get("username") is not enough ?



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Is-there-a-way-to-search-component-by-its-wicket-ID-tp4651175p4651217.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Is there a way to search component by its wicket ID ?

2012-08-14 Thread James Eliyezar
Because the id is unique only within the markup container of a component.
It need not be unique in a page. This is by design.
For more details refer:
https://cwiki.apache.org/WICKET/component-hierarchy.html


On Tue, Aug 14, 2012 at 3:42 PM, arkadyz111  wrote:

> But why we have to write "userForm" ? What is an idea behind of this ?
>
> Why get("username") is not enough ?
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Is-there-a-way-to-search-component-by-its-wicket-ID-tp4651175p4651217.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Thanks & regards
James Selvakumar
mcruncher.com


Re: Is there a way to search component by its wicket ID ?

2012-08-14 Thread nunofaria11
Hi there,

I'm not really sure if searching a component by its ID is a good idea - It
kinda' breaks modularity and goes against the OO approach. 

I have never searched a component by its ID but assuming you need the full
path (hierarchy) to it, such component will be hard to use in any other
context because you harcoded the path to that component.

Whenever I need to get access to a component I simply store it in a Map or
component List for later search and/or use.

Best regards
nuno





--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Is-there-a-way-to-search-component-by-its-wicket-ID-tp4651175p4651221.html
Sent from the Users forum mailing list archive at Nabble.com.

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



RE: Is there a way to search component by its wicket ID ?

2012-08-14 Thread Paul Bors
If you use wicket-component-expressions from com.googlecode.londonwicket you
can get to the list of all the components on the page that have that
"username" id via a regexp of "**:username", but as James mentioned earlier,
the ID is not unique and your wicket component tree might have such multiple
nodes (hence why wicket-component-expressions gives you a list of them).

I normally know that my panel has only one such component by the ID since I
developed it, so if I attach it to my page inside a panel with an ID like
"myPanel" then I use "**:myPanel:**:username" and I also filter by the
component type such as TextField.class to narrow down the search.

That's not production code, is unit test and I'm assuming that's the context
of your question. By using such regexp, I found myself refactoring the unit
test code less when shuffling panels on a page.

~ Thank you,
  Paul Bors

-Original Message-
From: James Eliyezar [mailto:ja...@mcruncher.com] 
Sent: Tuesday, August 14, 2012 4:12 AM
To: users@wicket.apache.org
Subject: Re: Is there a way to search component by its wicket ID ?

Because the id is unique only within the markup container of a component.
It need not be unique in a page. This is by design.
For more details refer:
https://cwiki.apache.org/WICKET/component-hierarchy.html


On Tue, Aug 14, 2012 at 3:42 PM, arkadyz111  wrote:

> But why we have to write "userForm" ? What is an idea behind of this ?
>
> Why get("username") is not enough ?
>
>
>
> --
> View this message in context:
>
http://apache-wicket.1842946.n4.nabble.com/Is-there-a-way-to-search-componen
t-by-its-wicket-ID-tp4651175p4651217.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Thanks & regards
James Selvakumar
mcruncher.com


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



Re: Is there a way to search component by its wicket ID ?

2012-08-15 Thread James Eliyezar
Thanks Paul for this nice tip.

On Tue, Aug 14, 2012 at 11:04 PM, Paul Bors  wrote:

> If you use wicket-component-expressions from com.googlecode.londonwicket
> you
> can get to the list of all the components on the page that have that
> "username" id via a regexp of "**:username", but as James mentioned
> earlier,
> the ID is not unique and your wicket component tree might have such
> multiple
> nodes (hence why wicket-component-expressions gives you a list of them).
>
> I normally know that my panel has only one such component by the ID since I
> developed it, so if I attach it to my page inside a panel with an ID like
> "myPanel" then I use "**:myPanel:**:username" and I also filter by the
> component type such as TextField.class to narrow down the search.
>
> That's not production code, is unit test and I'm assuming that's the
> context
> of your question. By using such regexp, I found myself refactoring the unit
> test code less when shuffling panels on a page.
>
> ~ Thank you,
>   Paul Bors
>
> -Original Message-
> From: James Eliyezar [mailto:ja...@mcruncher.com]
> Sent: Tuesday, August 14, 2012 4:12 AM
> To: users@wicket.apache.org
> Subject: Re: Is there a way to search component by its wicket ID ?
>
> Because the id is unique only within the markup container of a component.
> It need not be unique in a page. This is by design.
> For more details refer:
> https://cwiki.apache.org/WICKET/component-hierarchy.html
>
>
> On Tue, Aug 14, 2012 at 3:42 PM, arkadyz111  wrote:
>
> > But why we have to write "userForm" ? What is an idea behind of this ?
> >
> > Why get("username") is not enough ?
> >
> >
> >
> > --
> > View this message in context:
> >
>
> http://apache-wicket.1842946.n4.nabble.com/Is-there-a-way-to-search-componen
> t-by-its-wicket-ID-tp4651175p4651217.html
> > Sent from the Users forum mailing list archive at Nabble.com.
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > For additional commands, e-mail: users-h...@wicket.apache.org
> >
> >
>
>
> --
> Thanks & regards
> James Selvakumar
> mcruncher.com
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Thanks & regards
James Selvakumar
mcruncher.com