Re: Hippo's patch for wicket ids
On Thu, Oct 15, 2009 at 1:14 PM, Per Lundholm wrote: > Looks like a patch to make it easier to use Selenium to test your > webapplication. > > Selenium is very fond of id in tags. > Correct, this patch (PD) we use in order to get Selenium to work, and it works pretty well. What is basically the case is that Wicket uses a single global counter which ever increases to generate IDs. Because hierarchy can change, components are added this ID is not bound to the wicket component, leaving to a new ID the next time round. What this patch does is to tie the generated ID to the wicket component, but that's not the whole story because if anything is different in your hierarchy the paths will still change. It will work for selenium if you do everything exactly the same, but that's hard to maintain/ What you need is that when generating a ID, the ID is generated with the knowledge of the component, such that you can generate the ID based on the domain knowledge of your component. The crux is that the wicket method in the Session to generate an ID had no parameters, while if it would get the component requesting the ID, then an subclasses wicket Session instance can incorporate this knowlege. Basically the patch is just adding the parameter to that wicket method and the other 80% of the code is just making sure everything is backward compatible. How can one use this subclassing, well, for instance you have some kind of listing component on your page that enumerates items in your database. Because the content of the database changes, the hierarchy will change, rendering IDs useless. Now you could resolve this by letting the component that lists a single item explicitly set the markup ID, but if this itself is a Panel containing subitems, then you need to set the IDs of all those subitems too. That becomes nasty bit of either passing arguments or traversing the tree. However, with the patch you can put this logic in the session. When an ID needs to be generated, use the ancestor tree of the component for which the ID is needed up to a stable ID component (the one which knows which database element, and then instead of using a global counter, use a counter in that component. This was the ID has become stable, and most of the logic is where is belongs, the Session instance generating IDs. Maybe not the nicest example, because a lot of knowledge is infused in your Session class, but there are better cases available (we have a plugin system for wicket, where we can use a quite generic mechanism). It's illustrative though I hope. \Berry - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
RE: Hippo's patch for wicket ids
Works for me, your xpath must be wrong. Your syntax is ok. Either there is no element (link) with attribute wicketpath="tablePanel_leftList_tableList_pojoList_18_nameCell_namePanel Link_name" or there is no div tag inside an element... -Original Message- From: Douglas Ferguson [mailto:doug...@douglasferguson.us] Does anybody have sample of how to do this? I'm getting this error when I try to use the wicketpath [error] Element //a [...@wicketpath = 'tablePanel_leftList_tableList_pojoList_18_nameCell_namePanelLink_name ']/div not found - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Hippo's patch for wicket ids
Does anybody have sample of how to do this? I'm getting this error when I try to use the wicketpath [error] Element //a [...@wicketpath = 'tablePanel_leftList_tableList_pojoList_18_nameCell_namePanelLink_name ']/div not found On Oct 19, 2009, at 3:43 PM, Igor Vaynberg wrote: > you have to write your selenium tests to use that attribute instead of > the component id. > > -igor > > On Mon, Oct 19, 2009 at 1:39 PM, Douglas Ferguson > wrote: >> I added this: >> >> getDebugSettings().setOutputComponentPath(true); >> >> to my init() method but selenium is still not happy. >> Do I have to run wicket it development mode or something to get these >> settings to work? >> >> >> D/ >> >> On Oct 15, 2009, at 11:19 AM, Igor Vaynberg wrote: >> >>> the only drawback is that it makes your markup longer and that it >>> will >>> take slightly more cpu because the page-relative path has to be >>> computed for every component on the page. >>> >>> -igor >>> >>> On Thu, Oct 15, 2009 at 9:04 AM, Douglas Ferguson >>> wrote: Is there any drawback to using this in production? On Oct 15, 2009, at 10:53 AM, Igor Vaynberg wrote: > see idebugsettings.setoutputcomponentpath, this will add > wicket:path='component's page relative path' attribute which is > stable > as long as you do not change the hierarchy and can be used for > writing > selenium tests. > > -igor > > On Thu, Oct 15, 2009 at 4:14 AM, Per Lundholm > wrote: >> Looks like a patch to make it easier to use Selenium to test your >> webapplication. >> >> Selenium is very fond of id in tags. >> >> /Per >> >> On Thu, Oct 15, 2009 at 9:58 AM, Daniel Frisk >> wrote: >>> Ok, I'm lazy and couldn't decipher that code at a glance. What >>> does it do? >>> >>> // Daniel >>> jalbum.net >>> >>> >>> >>> On 2009-10-15, at 03:09, Douglas Ferguson wrote: >>> Has anybody seen this: http://www.onehippo.org/cms7/integration_testing.html Seems like a nice alternative vs. having to set markupIds on all components. Thoughts? They have a patch for wicket: > Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/ > Session.java > = > = > = > = > = > == > *** jdk-1.4/wicket/src/main/java/org/apache/wicket/ > Session.java > (revision 724306) > --- jdk-1.4/wicket/src/main/java/org/apache/wicket/ > Session.java > (working copy) > *** > *** 1475,1478 > --- 1475,1489 >{ >return sequence++; >} > + > + /** > +* Retrieves the next available session-unique value > for > the > supplied Component > +* > +* @param component > +*the component which requests the > generation of a > markup identifier > +* @return session-unique value > +*/ > + public Object getMarkupId(Component component) { > + return new Integer(nextSequenceValue()); > + } > } > Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/ > Component.java > = > = > = > = > = > == > *** jdk-1.4/wicket/src/main/java/org/apache/wicket/ > Component.java > (revision 724306) > --- jdk-1.4/wicket/src/main/java/org/apache/wicket/ > Component.java > (working copy) > *** > *** 1426,1437 >return null; >} > > ! final int generatedMarkupId = storedMarkupId > instanceof > Integer > ! ? ((Integer)storedMarkupId).intValue > () : > Session.get > ().nextSequenceValue(); > ! > ! if (storedMarkupId == null) > ! { > ! setMarkupIdImpl(new Integer > (generatedMarkupId)); >} > >// try to read from markup > --- 1426,1445 >return null; >} > > ! String markupIdPostfix; > ! if (!(storedMarkupId instanceof Integer)) { > ! Object markupIdFromSession = > Session.get().getMarkupId(this); > ! if (storedMar
Re: Hippo's patch for wicket ids
Ah... I guess you can't use the selenium recorder then. D/ On Oct 19, 2009, at 3:43 PM, Igor Vaynberg wrote: > you have to write your selenium tests to use that attribute instead of > the component id. > > -igor > > On Mon, Oct 19, 2009 at 1:39 PM, Douglas Ferguson > wrote: >> I added this: >> >> getDebugSettings().setOutputComponentPath(true); >> >> to my init() method but selenium is still not happy. >> Do I have to run wicket it development mode or something to get these >> settings to work? >> >> >> D/ >> >> On Oct 15, 2009, at 11:19 AM, Igor Vaynberg wrote: >> >>> the only drawback is that it makes your markup longer and that it >>> will >>> take slightly more cpu because the page-relative path has to be >>> computed for every component on the page. >>> >>> -igor >>> >>> On Thu, Oct 15, 2009 at 9:04 AM, Douglas Ferguson >>> wrote: Is there any drawback to using this in production? On Oct 15, 2009, at 10:53 AM, Igor Vaynberg wrote: > see idebugsettings.setoutputcomponentpath, this will add > wicket:path='component's page relative path' attribute which is > stable > as long as you do not change the hierarchy and can be used for > writing > selenium tests. > > -igor > > On Thu, Oct 15, 2009 at 4:14 AM, Per Lundholm > wrote: >> Looks like a patch to make it easier to use Selenium to test your >> webapplication. >> >> Selenium is very fond of id in tags. >> >> /Per >> >> On Thu, Oct 15, 2009 at 9:58 AM, Daniel Frisk >> wrote: >>> Ok, I'm lazy and couldn't decipher that code at a glance. What >>> does it do? >>> >>> // Daniel >>> jalbum.net >>> >>> >>> >>> On 2009-10-15, at 03:09, Douglas Ferguson wrote: >>> Has anybody seen this: http://www.onehippo.org/cms7/integration_testing.html Seems like a nice alternative vs. having to set markupIds on all components. Thoughts? They have a patch for wicket: > Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/ > Session.java > = > = > = > = > = > == > *** jdk-1.4/wicket/src/main/java/org/apache/wicket/ > Session.java > (revision 724306) > --- jdk-1.4/wicket/src/main/java/org/apache/wicket/ > Session.java > (working copy) > *** > *** 1475,1478 > --- 1475,1489 >{ >return sequence++; >} > + > + /** > +* Retrieves the next available session-unique value > for > the > supplied Component > +* > +* @param component > +*the component which requests the > generation of a > markup identifier > +* @return session-unique value > +*/ > + public Object getMarkupId(Component component) { > + return new Integer(nextSequenceValue()); > + } > } > Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/ > Component.java > = > = > = > = > = > == > *** jdk-1.4/wicket/src/main/java/org/apache/wicket/ > Component.java > (revision 724306) > --- jdk-1.4/wicket/src/main/java/org/apache/wicket/ > Component.java > (working copy) > *** > *** 1426,1437 >return null; >} > > ! final int generatedMarkupId = storedMarkupId > instanceof > Integer > ! ? ((Integer)storedMarkupId).intValue > () : > Session.get > ().nextSequenceValue(); > ! > ! if (storedMarkupId == null) > ! { > ! setMarkupIdImpl(new Integer > (generatedMarkupId)); >} > >// try to read from markup > --- 1426,1445 >return null; >} > > ! String markupIdPostfix; > ! if (!(storedMarkupId instanceof Integer)) { > ! Object markupIdFromSession = > Session.get().getMarkupId(this); > ! if (storedMarkupId == null && > markupIdFromSession > != null) { > ! setMarkupIdImpl > (markupIdFromSession); > !
Re: Hippo's patch for wicket ids
you have to write your selenium tests to use that attribute instead of the component id. -igor On Mon, Oct 19, 2009 at 1:39 PM, Douglas Ferguson wrote: > I added this: > > getDebugSettings().setOutputComponentPath(true); > > to my init() method but selenium is still not happy. > Do I have to run wicket it development mode or something to get these > settings to work? > > > D/ > > On Oct 15, 2009, at 11:19 AM, Igor Vaynberg wrote: > >> the only drawback is that it makes your markup longer and that it will >> take slightly more cpu because the page-relative path has to be >> computed for every component on the page. >> >> -igor >> >> On Thu, Oct 15, 2009 at 9:04 AM, Douglas Ferguson >> wrote: >>> Is there any drawback to using this in production? >>> >>> >>> On Oct 15, 2009, at 10:53 AM, Igor Vaynberg wrote: >>> see idebugsettings.setoutputcomponentpath, this will add wicket:path='component's page relative path' attribute which is stable as long as you do not change the hierarchy and can be used for writing selenium tests. -igor On Thu, Oct 15, 2009 at 4:14 AM, Per Lundholm wrote: > Looks like a patch to make it easier to use Selenium to test your > webapplication. > > Selenium is very fond of id in tags. > > /Per > > On Thu, Oct 15, 2009 at 9:58 AM, Daniel Frisk > wrote: >> Ok, I'm lazy and couldn't decipher that code at a glance. What >> does it do? >> >> // Daniel >> jalbum.net >> >> >> >> On 2009-10-15, at 03:09, Douglas Ferguson wrote: >> >>> Has anybody seen this: >>> >>> http://www.onehippo.org/cms7/integration_testing.html >>> >>> Seems like a nice alternative vs. having to set markupIds on all >>> components. >>> >>> Thoughts? >>> >>> >>> >>> They have a patch for wicket: >>> Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/ Session.java = = = *** jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java (revision 724306) --- jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java (working copy) *** *** 1475,1478 --- 1475,1489 { return sequence++; } + + /** + * Retrieves the next available session-unique value for the supplied Component + * + * @param component + * the component which requests the generation of a markup identifier + * @return session-unique value + */ + public Object getMarkupId(Component component) { + return new Integer(nextSequenceValue()); + } } Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/ Component.java = = = *** jdk-1.4/wicket/src/main/java/org/apache/wicket/ Component.java (revision 724306) --- jdk-1.4/wicket/src/main/java/org/apache/wicket/ Component.java (working copy) *** *** 1426,1437 return null; } ! final int generatedMarkupId = storedMarkupId instanceof Integer ! ? ((Integer)storedMarkupId).intValue() : Session.get ().nextSequenceValue(); ! ! if (storedMarkupId == null) ! { ! setMarkupIdImpl(new Integer (generatedMarkupId)); } // try to read from markup --- 1426,1445 return null; } ! String markupIdPostfix; ! if (!(storedMarkupId instanceof Integer)) { ! Object markupIdFromSession = Session.get().getMarkupId(this); ! if (storedMarkupId == null && markupIdFromSession != null) { ! setMarkupIdImpl (markupIdFromSession); ! } ! storedMarkupId = markupIdFromSession; ! } ! if (storedMarkupId instanceof Integer) { ! markupIdPostfix = Integer.toHexString (((Integer) storedMarkupId).intValue()).toLowerCase(); ! } else if (storedMarkupId inst
Re: Hippo's patch for wicket ids
I added this: getDebugSettings().setOutputComponentPath(true); to my init() method but selenium is still not happy. Do I have to run wicket it development mode or something to get these settings to work? D/ On Oct 15, 2009, at 11:19 AM, Igor Vaynberg wrote: > the only drawback is that it makes your markup longer and that it will > take slightly more cpu because the page-relative path has to be > computed for every component on the page. > > -igor > > On Thu, Oct 15, 2009 at 9:04 AM, Douglas Ferguson > wrote: >> Is there any drawback to using this in production? >> >> >> On Oct 15, 2009, at 10:53 AM, Igor Vaynberg wrote: >> >>> see idebugsettings.setoutputcomponentpath, this will add >>> wicket:path='component's page relative path' attribute which is >>> stable >>> as long as you do not change the hierarchy and can be used for >>> writing >>> selenium tests. >>> >>> -igor >>> >>> On Thu, Oct 15, 2009 at 4:14 AM, Per Lundholm >>> wrote: Looks like a patch to make it easier to use Selenium to test your webapplication. Selenium is very fond of id in tags. /Per On Thu, Oct 15, 2009 at 9:58 AM, Daniel Frisk wrote: > Ok, I'm lazy and couldn't decipher that code at a glance. What > does it do? > > // Daniel > jalbum.net > > > > On 2009-10-15, at 03:09, Douglas Ferguson wrote: > >> Has anybody seen this: >> >> http://www.onehippo.org/cms7/integration_testing.html >> >> Seems like a nice alternative vs. having to set markupIds on all >> components. >> >> Thoughts? >> >> >> >> They have a patch for wicket: >> >>> Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/ >>> Session.java >>> = >>> = >>> = >>> >>> *** jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java >>> (revision 724306) >>> --- jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java >>> (working copy) >>> *** >>> *** 1475,1478 >>> --- 1475,1489 >>>{ >>>return sequence++; >>>} >>> + >>> + /** >>> +* Retrieves the next available session-unique value for >>> the >>> supplied Component >>> +* >>> +* @param component >>> +*the component which requests the >>> generation of a >>> markup identifier >>> +* @return session-unique value >>> +*/ >>> + public Object getMarkupId(Component component) { >>> + return new Integer(nextSequenceValue()); >>> + } >>> } >>> Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/ >>> Component.java >>> = >>> = >>> = >>> >>> *** jdk-1.4/wicket/src/main/java/org/apache/wicket/ >>> Component.java >>> (revision 724306) >>> --- jdk-1.4/wicket/src/main/java/org/apache/wicket/ >>> Component.java >>> (working copy) >>> *** >>> *** 1426,1437 >>>return null; >>>} >>> >>> ! final int generatedMarkupId = storedMarkupId >>> instanceof >>> Integer >>> ! ? ((Integer)storedMarkupId).intValue() : >>> Session.get >>> ().nextSequenceValue(); >>> ! >>> ! if (storedMarkupId == null) >>> ! { >>> ! setMarkupIdImpl(new Integer >>> (generatedMarkupId)); >>>} >>> >>>// try to read from markup >>> --- 1426,1445 >>>return null; >>>} >>> >>> ! String markupIdPostfix; >>> ! if (!(storedMarkupId instanceof Integer)) { >>> ! Object markupIdFromSession = >>> Session.get().getMarkupId(this); >>> ! if (storedMarkupId == null && >>> markupIdFromSession >>> != null) { >>> ! setMarkupIdImpl >>> (markupIdFromSession); >>> ! } >>> ! storedMarkupId = markupIdFromSession; >>> ! } >>> ! if (storedMarkupId instanceof Integer) { >>> ! markupIdPostfix = Integer.toHexString >>> (((Integer) >>> storedMarkupId).intValue()).toLowerCase(); >>> ! } else if (storedMarkupId instanceof String) { >>> ! return (String) storedMarkupId; >>> ! } else { >>> ! markupIdPostfix = >>> storedMarkupId.toString >>> (); >>>} >>> >>>// try to read from markup >>> *
Re: Hippo's patch for wicket ids
the only drawback is that it makes your markup longer and that it will take slightly more cpu because the page-relative path has to be computed for every component on the page. -igor On Thu, Oct 15, 2009 at 9:04 AM, Douglas Ferguson wrote: > Is there any drawback to using this in production? > > > On Oct 15, 2009, at 10:53 AM, Igor Vaynberg wrote: > >> see idebugsettings.setoutputcomponentpath, this will add >> wicket:path='component's page relative path' attribute which is stable >> as long as you do not change the hierarchy and can be used for writing >> selenium tests. >> >> -igor >> >> On Thu, Oct 15, 2009 at 4:14 AM, Per Lundholm >> wrote: >>> Looks like a patch to make it easier to use Selenium to test your >>> webapplication. >>> >>> Selenium is very fond of id in tags. >>> >>> /Per >>> >>> On Thu, Oct 15, 2009 at 9:58 AM, Daniel Frisk >>> wrote: Ok, I'm lazy and couldn't decipher that code at a glance. What does it do? // Daniel jalbum.net On 2009-10-15, at 03:09, Douglas Ferguson wrote: > Has anybody seen this: > > http://www.onehippo.org/cms7/integration_testing.html > > Seems like a nice alternative vs. having to set markupIds on all > components. > > Thoughts? > > > > They have a patch for wicket: > >> Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java >> = >> == >> *** jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java >> (revision 724306) >> --- jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java >> (working copy) >> *** >> *** 1475,1478 >> --- 1475,1489 >> { >> return sequence++; >> } >> + >> + /** >> + * Retrieves the next available session-unique value for >> the >> supplied Component >> + * >> + * @param component >> + * the component which requests the >> generation of a >> markup identifier >> + * @return session-unique value >> + */ >> + public Object getMarkupId(Component component) { >> + return new Integer(nextSequenceValue()); >> + } >> } >> Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/ >> Component.java >> = >> == >> *** jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java >> (revision 724306) >> --- jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java >> (working copy) >> *** >> *** 1426,1437 >> return null; >> } >> >> ! final int generatedMarkupId = storedMarkupId >> instanceof >> Integer >> ! ? ((Integer)storedMarkupId).intValue() : >> Session.get >> ().nextSequenceValue(); >> ! >> ! if (storedMarkupId == null) >> ! { >> ! setMarkupIdImpl(new Integer >> (generatedMarkupId)); >> } >> >> // try to read from markup >> --- 1426,1445 >> return null; >> } >> >> ! String markupIdPostfix; >> ! if (!(storedMarkupId instanceof Integer)) { >> ! Object markupIdFromSession = >> Session.get().getMarkupId(this); >> ! if (storedMarkupId == null && >> markupIdFromSession >> != null) { >> ! setMarkupIdImpl >> (markupIdFromSession); >> ! } >> ! storedMarkupId = markupIdFromSession; >> ! } >> ! if (storedMarkupId instanceof Integer) { >> ! markupIdPostfix = Integer.toHexString >> (((Integer) >> storedMarkupId).intValue()).toLowerCase(); >> ! } else if (storedMarkupId instanceof String) { >> ! return (String) storedMarkupId; >> ! } else { >> ! markupIdPostfix = storedMarkupId.toString >> (); >> } >> >> // try to read from markup >> *** >> *** 1449,1455 >> markupIdPrefix = getId(); >> } >> >> - String markupIdPostfix = Integer.toHexString >> (generatedMarkupId).toLowerCase(); >> markupIdPostfix = RequestContext.get >> ().encodeMarkupId >> (markupIdPostfix); >> >> String markupId = markupIdPrefix + markupIdPostfix; >> --- 1457,1462 > > > Then in their session, they re
Re: Hippo's patch for wicket ids
Is there any drawback to using this in production? On Oct 15, 2009, at 10:53 AM, Igor Vaynberg wrote: > see idebugsettings.setoutputcomponentpath, this will add > wicket:path='component's page relative path' attribute which is stable > as long as you do not change the hierarchy and can be used for writing > selenium tests. > > -igor > > On Thu, Oct 15, 2009 at 4:14 AM, Per Lundholm > wrote: >> Looks like a patch to make it easier to use Selenium to test your >> webapplication. >> >> Selenium is very fond of id in tags. >> >> /Per >> >> On Thu, Oct 15, 2009 at 9:58 AM, Daniel Frisk >> wrote: >>> Ok, I'm lazy and couldn't decipher that code at a glance. What >>> does it do? >>> >>> // Daniel >>> jalbum.net >>> >>> >>> >>> On 2009-10-15, at 03:09, Douglas Ferguson wrote: >>> Has anybody seen this: http://www.onehippo.org/cms7/integration_testing.html Seems like a nice alternative vs. having to set markupIds on all components. Thoughts? They have a patch for wicket: > Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java > = > == > *** jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java > (revision 724306) > --- jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java > (working copy) > *** > *** 1475,1478 > --- 1475,1489 >{ >return sequence++; >} > + > + /** > +* Retrieves the next available session-unique value for > the > supplied Component > +* > +* @param component > +*the component which requests the > generation of a > markup identifier > +* @return session-unique value > +*/ > + public Object getMarkupId(Component component) { > + return new Integer(nextSequenceValue()); > + } > } > Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/ > Component.java > = > == > *** jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java > (revision 724306) > --- jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java > (working copy) > *** > *** 1426,1437 >return null; >} > > ! final int generatedMarkupId = storedMarkupId > instanceof > Integer > ! ? ((Integer)storedMarkupId).intValue() : > Session.get > ().nextSequenceValue(); > ! > ! if (storedMarkupId == null) > ! { > ! setMarkupIdImpl(new Integer > (generatedMarkupId)); >} > >// try to read from markup > --- 1426,1445 >return null; >} > > ! String markupIdPostfix; > ! if (!(storedMarkupId instanceof Integer)) { > ! Object markupIdFromSession = > Session.get().getMarkupId(this); > ! if (storedMarkupId == null && > markupIdFromSession > != null) { > ! setMarkupIdImpl > (markupIdFromSession); > ! } > ! storedMarkupId = markupIdFromSession; > ! } > ! if (storedMarkupId instanceof Integer) { > ! markupIdPostfix = Integer.toHexString > (((Integer) > storedMarkupId).intValue()).toLowerCase(); > ! } else if (storedMarkupId instanceof String) { > ! return (String) storedMarkupId; > ! } else { > ! markupIdPostfix = storedMarkupId.toString > (); >} > >// try to read from markup > *** > *** 1449,1455 >markupIdPrefix = getId(); >} > > - String markupIdPostfix = Integer.toHexString > (generatedMarkupId).toLowerCase(); >markupIdPostfix = RequestContext.get > ().encodeMarkupId > (markupIdPostfix); > >String markupId = markupIdPrefix + markupIdPostfix; > --- 1457,1462 Then in their session, they return stable ids > private Map pluginComponentCounters = new > HashMap(); > > // Do not add the @Override annotation on this > public Object getMarkupId(Component component) { > String markupId = null; > for (Component ancestor=component.getParent(); ancestor! > =null && markupId==null; ancestor=ancestor.getParent
Re: Hippo's patch for wicket ids
see idebugsettings.setoutputcomponentpath, this will add wicket:path='component's page relative path' attribute which is stable as long as you do not change the hierarchy and can be used for writing selenium tests. -igor On Thu, Oct 15, 2009 at 4:14 AM, Per Lundholm wrote: > Looks like a patch to make it easier to use Selenium to test your > webapplication. > > Selenium is very fond of id in tags. > > /Per > > On Thu, Oct 15, 2009 at 9:58 AM, Daniel Frisk wrote: >> Ok, I'm lazy and couldn't decipher that code at a glance. What does it do? >> >> // Daniel >> jalbum.net >> >> >> >> On 2009-10-15, at 03:09, Douglas Ferguson wrote: >> >>> Has anybody seen this: >>> >>> http://www.onehippo.org/cms7/integration_testing.html >>> >>> Seems like a nice alternative vs. having to set markupIds on all >>> components. >>> >>> Thoughts? >>> >>> >>> >>> They have a patch for wicket: >>> Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java === *** jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java (revision 724306) --- jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java (working copy) *** *** 1475,1478 --- 1475,1489 { return sequence++; } + + /** + * Retrieves the next available session-unique value for the supplied Component + * + * @param component + * the component which requests the generation of a markup identifier + * @return session-unique value + */ + public Object getMarkupId(Component component) { + return new Integer(nextSequenceValue()); + } } Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java === *** jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java (revision 724306) --- jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java (working copy) *** *** 1426,1437 return null; } ! final int generatedMarkupId = storedMarkupId instanceof Integer ! ? ((Integer)storedMarkupId).intValue() : Session.get ().nextSequenceValue(); ! ! if (storedMarkupId == null) ! { ! setMarkupIdImpl(new Integer(generatedMarkupId)); } // try to read from markup --- 1426,1445 return null; } ! String markupIdPostfix; ! if (!(storedMarkupId instanceof Integer)) { ! Object markupIdFromSession = Session.get().getMarkupId(this); ! if (storedMarkupId == null && markupIdFromSession != null) { ! setMarkupIdImpl(markupIdFromSession); ! } ! storedMarkupId = markupIdFromSession; ! } ! if (storedMarkupId instanceof Integer) { ! markupIdPostfix = Integer.toHexString(((Integer) storedMarkupId).intValue()).toLowerCase(); ! } else if (storedMarkupId instanceof String) { ! return (String) storedMarkupId; ! } else { ! markupIdPostfix = storedMarkupId.toString(); } // try to read from markup *** *** 1449,1455 markupIdPrefix = getId(); } - String markupIdPostfix = Integer.toHexString (generatedMarkupId).toLowerCase(); markupIdPostfix = RequestContext.get().encodeMarkupId (markupIdPostfix); String markupId = markupIdPrefix + markupIdPostfix; --- 1457,1462 >>> >>> >>> Then in their session, they return stable ids >>> private Map pluginComponentCounters = new HashMap(); // Do not add the @Override annotation on this public Object getMarkupId(Component component) { String markupId = null; for (Component ancestor=component.getParent(); ancestor! =null && markupId==null; ancestor=ancestor.getParent()) { if (ancestor instanceof IPlugin || ancestor instanceof Home) { markupId = ancestor.getMarkupId(true); break; } } if (markupId == null) { return "root"; } int componentNum = 0; if (pluginComponentCounters.cont
Re: Hippo's patch for wicket ids
Looks like a patch to make it easier to use Selenium to test your webapplication. Selenium is very fond of id in tags. /Per On Thu, Oct 15, 2009 at 9:58 AM, Daniel Frisk wrote: > Ok, I'm lazy and couldn't decipher that code at a glance. What does it do? > > // Daniel > jalbum.net > > > > On 2009-10-15, at 03:09, Douglas Ferguson wrote: > >> Has anybody seen this: >> >> http://www.onehippo.org/cms7/integration_testing.html >> >> Seems like a nice alternative vs. having to set markupIds on all >> components. >> >> Thoughts? >> >> >> >> They have a patch for wicket: >> >>> Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java >>> === >>> *** jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java >>> (revision 724306) >>> --- jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java >>> (working copy) >>> *** >>> *** 1475,1478 >>> --- 1475,1489 >>> { >>> return sequence++; >>> } >>> + >>> + /** >>> + * Retrieves the next available session-unique value for the >>> supplied Component >>> + * >>> + * @param component >>> + * the component which requests the generation of a >>> markup identifier >>> + * @return session-unique value >>> + */ >>> + public Object getMarkupId(Component component) { >>> + return new Integer(nextSequenceValue()); >>> + } >>> } >>> Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java >>> === >>> *** jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java >>> (revision 724306) >>> --- jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java >>> (working copy) >>> *** >>> *** 1426,1437 >>> return null; >>> } >>> >>> ! final int generatedMarkupId = storedMarkupId instanceof >>> Integer >>> ! ? ((Integer)storedMarkupId).intValue() : >>> Session.get >>> ().nextSequenceValue(); >>> ! >>> ! if (storedMarkupId == null) >>> ! { >>> ! setMarkupIdImpl(new Integer(generatedMarkupId)); >>> } >>> >>> // try to read from markup >>> --- 1426,1445 >>> return null; >>> } >>> >>> ! String markupIdPostfix; >>> ! if (!(storedMarkupId instanceof Integer)) { >>> ! Object markupIdFromSession = >>> Session.get().getMarkupId(this); >>> ! if (storedMarkupId == null && markupIdFromSession >>> != null) { >>> ! setMarkupIdImpl(markupIdFromSession); >>> ! } >>> ! storedMarkupId = markupIdFromSession; >>> ! } >>> ! if (storedMarkupId instanceof Integer) { >>> ! markupIdPostfix = Integer.toHexString(((Integer) >>> storedMarkupId).intValue()).toLowerCase(); >>> ! } else if (storedMarkupId instanceof String) { >>> ! return (String) storedMarkupId; >>> ! } else { >>> ! markupIdPostfix = storedMarkupId.toString(); >>> } >>> >>> // try to read from markup >>> *** >>> *** 1449,1455 >>> markupIdPrefix = getId(); >>> } >>> >>> - String markupIdPostfix = Integer.toHexString >>> (generatedMarkupId).toLowerCase(); >>> markupIdPostfix = RequestContext.get().encodeMarkupId >>> (markupIdPostfix); >>> >>> String markupId = markupIdPrefix + markupIdPostfix; >>> --- 1457,1462 >> >> >> Then in their session, they return stable ids >> >>> private Map pluginComponentCounters = new >>> HashMap(); >>> >>> // Do not add the @Override annotation on this >>> public Object getMarkupId(Component component) { >>> String markupId = null; >>> for (Component ancestor=component.getParent(); ancestor! >>> =null && markupId==null; ancestor=ancestor.getParent()) { >>> if (ancestor instanceof IPlugin || ancestor instanceof >>> Home) { >>> markupId = ancestor.getMarkupId(true); >>> break; >>> } >>> } >>> if (markupId == null) { >>> return "root"; >>> } >>> int componentNum = 0; >>> if (pluginComponentCounters.containsKey(markupId)) { >>> componentNum = pluginComponentCounters.get >>> (markupId).intValue(); >>> } >>> ++componentNum; >>> pluginComponentCounters.put(markupId, new Integer >>> (componentNum)); >>> return markupId + "_" + componentNum; >>> } >>> } >> >> >> - >> To unsubscribe, e-mail: users-unsubscr...@wicket.apa
Re: Hippo's patch for wicket ids
Ok, I'm lazy and couldn't decipher that code at a glance. What does it do? // Daniel jalbum.net On 2009-10-15, at 03:09, Douglas Ferguson wrote: Has anybody seen this: http://www.onehippo.org/cms7/integration_testing.html Seems like a nice alternative vs. having to set markupIds on all components. Thoughts? They have a patch for wicket: Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java === *** jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java (revision 724306) --- jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java (working copy) *** *** 1475,1478 --- 1475,1489 { return sequence++; } + + /** +* Retrieves the next available session-unique value for the supplied Component +* +* @param component +*the component which requests the generation of a markup identifier +* @return session-unique value +*/ + public Object getMarkupId(Component component) { + return new Integer(nextSequenceValue()); + } } Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java === *** jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java (revision 724306) --- jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java (working copy) *** *** 1426,1437 return null; } ! final int generatedMarkupId = storedMarkupId instanceof Integer ! ? ((Integer)storedMarkupId).intValue() : Session.get ().nextSequenceValue(); ! ! if (storedMarkupId == null) ! { ! setMarkupIdImpl(new Integer(generatedMarkupId)); } // try to read from markup --- 1426,1445 return null; } ! String markupIdPostfix; ! if (!(storedMarkupId instanceof Integer)) { ! Object markupIdFromSession = Session.get().getMarkupId(this); ! if (storedMarkupId == null && markupIdFromSession != null) { ! setMarkupIdImpl(markupIdFromSession); ! } ! storedMarkupId = markupIdFromSession; ! } ! if (storedMarkupId instanceof Integer) { ! markupIdPostfix = Integer.toHexString(((Integer) storedMarkupId).intValue()).toLowerCase(); ! } else if (storedMarkupId instanceof String) { ! return (String) storedMarkupId; ! } else { ! markupIdPostfix = storedMarkupId.toString(); } // try to read from markup *** *** 1449,1455 markupIdPrefix = getId(); } - String markupIdPostfix = Integer.toHexString (generatedMarkupId).toLowerCase(); markupIdPostfix = RequestContext.get().encodeMarkupId (markupIdPostfix); String markupId = markupIdPrefix + markupIdPostfix; --- 1457,1462 Then in their session, they return stable ids private Map pluginComponentCounters = new HashMap(); // Do not add the @Override annotation on this public Object getMarkupId(Component component) { String markupId = null; for (Component ancestor=component.getParent(); ancestor! =null && markupId==null; ancestor=ancestor.getParent()) { if (ancestor instanceof IPlugin || ancestor instanceof Home) { markupId = ancestor.getMarkupId(true); break; } } if (markupId == null) { return "root"; } int componentNum = 0; if (pluginComponentCounters.containsKey(markupId)) { componentNum = pluginComponentCounters.get (markupId).intValue(); } ++componentNum; pluginComponentCounters.put(markupId, new Integer (componentNum)); return markupId + "_" + componentNum; } } - 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
Hippo's patch for wicket ids
Has anybody seen this: http://www.onehippo.org/cms7/integration_testing.html Seems like a nice alternative vs. having to set markupIds on all components. Thoughts? They have a patch for wicket: > Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java > === > *** jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java > (revision 724306) > --- jdk-1.4/wicket/src/main/java/org/apache/wicket/Session.java > (working copy) > *** > *** 1475,1478 > --- 1475,1489 > { > return sequence++; > } > + > + /** > + * Retrieves the next available session-unique value for the > supplied Component > + * > + * @param component > + *the component which requests the generation of a > markup identifier > + * @return session-unique value > + */ > + public Object getMarkupId(Component component) { > + return new Integer(nextSequenceValue()); > + } > } > Index: jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java > === > *** jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java > (revision 724306) > --- jdk-1.4/wicket/src/main/java/org/apache/wicket/Component.java > (working copy) > *** > *** 1426,1437 > return null; > } > > ! final int generatedMarkupId = storedMarkupId instanceof Integer > ! ? ((Integer)storedMarkupId).intValue() : Session.get > ().nextSequenceValue(); > ! > ! if (storedMarkupId == null) > ! { > ! setMarkupIdImpl(new Integer(generatedMarkupId)); > } > > // try to read from markup > --- 1426,1445 > return null; > } > > ! String markupIdPostfix; > ! if (!(storedMarkupId instanceof Integer)) { > ! Object markupIdFromSession = > Session.get().getMarkupId(this); > ! if (storedMarkupId == null && markupIdFromSession != > null) { > ! setMarkupIdImpl(markupIdFromSession); > ! } > ! storedMarkupId = markupIdFromSession; > ! } > ! if (storedMarkupId instanceof Integer) { > ! markupIdPostfix = Integer.toHexString(((Integer) > storedMarkupId).intValue()).toLowerCase(); > ! } else if (storedMarkupId instanceof String) { > ! return (String) storedMarkupId; > ! } else { > ! markupIdPostfix = storedMarkupId.toString(); > } > > // try to read from markup > *** > *** 1449,1455 > markupIdPrefix = getId(); > } > > - String markupIdPostfix = Integer.toHexString > (generatedMarkupId).toLowerCase(); > markupIdPostfix = RequestContext.get().encodeMarkupId > (markupIdPostfix); > > String markupId = markupIdPrefix + markupIdPostfix; > --- 1457,1462 Then in their session, they return stable ids > private Map pluginComponentCounters = new > HashMap(); > > // Do not add the @Override annotation on this > public Object getMarkupId(Component component) { > String markupId = null; > for (Component ancestor=component.getParent(); ancestor! > =null && markupId==null; ancestor=ancestor.getParent()) { > if (ancestor instanceof IPlugin || ancestor instanceof > Home) { > markupId = ancestor.getMarkupId(true); > break; > } > } > if (markupId == null) { > return "root"; > } > int componentNum = 0; > if (pluginComponentCounters.containsKey(markupId)) { > componentNum = pluginComponentCounters.get > (markupId).intValue(); > } > ++componentNum; > pluginComponentCounters.put(markupId, new Integer > (componentNum)); > return markupId + "_" + componentNum; > } > } - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org