Hippo's patch for wicket ids

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Hippo's patch for wicket ids

Douglas Ferguson
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<String,Integer> pluginComponentCounters = new  
> HashMap<String,Integer>();
>
>     // 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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Hippo's patch for wicket ids

Daniel Frisk
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<String,Integer> pluginComponentCounters = new
>> HashMap<String,Integer>();
>>
>>    // 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Hippo's patch for wicket ids

Per Lundholm
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 <[hidden email]> 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<String,Integer> pluginComponentCounters = new
>>> HashMap<String,Integer>();
>>>
>>>   // 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: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Hippo's patch for wicket ids

Igor Vaynberg-2
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 <[hidden email]> 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 <[hidden email]> 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<String,Integer> pluginComponentCounters = new
>>>> HashMap<String,Integer>();
>>>>
>>>>   // 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: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Hippo's patch for wicket ids

Douglas Ferguson
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  
> <[hidden email]> 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 <[hidden email]>  
>> 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<String,Integer> pluginComponentCounters = new
>>>>> HashMap<String,Integer>();
>>>>>
>>>>>   // 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: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Hippo's patch for wicket ids

Igor Vaynberg-2
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
<[hidden email]> 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
>> <[hidden email]> 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 <[hidden email]>
>>> 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<String,Integer> pluginComponentCounters = new
>>>>>> HashMap<String,Integer>();
>>>>>>
>>>>>>   // 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: [hidden email]
>>>>> For additional commands, e-mail: [hidden email]
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Hippo's patch for wicket ids

Douglas Ferguson
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
> <[hidden email]> 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
>>> <[hidden email]> 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 <[hidden email]>
>>>> 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<String,Integer> pluginComponentCounters = new
>>>>>>> HashMap<String,Integer>();
>>>>>>>
>>>>>>>   // 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: [hidden email]
>>>>>> For additional commands, e-mail: [hidden email]
>>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: [hidden email]
>>>>> For additional commands, e-mail: [hidden email]
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Hippo's patch for wicket ids

Igor Vaynberg-2
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
<[hidden email]> 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
>> <[hidden email]> 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
>>>> <[hidden email]> 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 <[hidden email]>
>>>>> 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<String,Integer> pluginComponentCounters = new
>>>>>>>> HashMap<String,Integer>();
>>>>>>>>
>>>>>>>>   // 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: [hidden email]
>>>>>>> For additional commands, e-mail: [hidden email]
>>>>>>>
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: [hidden email]
>>>>>> For additional commands, e-mail: [hidden email]
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: [hidden email]
>>>>> For additional commands, e-mail: [hidden email]
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Hippo's patch for wicket ids

Douglas Ferguson
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
> <[hidden email]> 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
>>> <[hidden email]> 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
>>>>> <[hidden email]> 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 <[hidden email]>
>>>>>> 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<String,Integer> pluginComponentCounters = new
>>>>>>>>> HashMap<String,Integer>();
>>>>>>>>>
>>>>>>>>>   // 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: [hidden email]
>>>>>>>> For additional commands, e-mail: [hidden email]
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: [hidden email]
>>>>>>> For additional commands, e-mail: [hidden email]
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: [hidden email]
>>>>>> For additional commands, e-mail: [hidden email]
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: [hidden email]
>>>>> For additional commands, e-mail: [hidden email]
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Hippo's patch for wicket ids

Douglas Ferguson
In reply to this post by Igor Vaynberg-2
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
> <[hidden email]> 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
>>> <[hidden email]> 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
>>>>> <[hidden email]> 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 <[hidden email]>
>>>>>> 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<String,Integer> pluginComponentCounters = new
>>>>>>>>> HashMap<String,Integer>();
>>>>>>>>>
>>>>>>>>>   // 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: [hidden email]
>>>>>>>> For additional commands, e-mail: [hidden email]
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: [hidden email]
>>>>>>> For additional commands, e-mail: [hidden email]
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: [hidden email]
>>>>>> For additional commands, e-mail: [hidden email]
>>>>>>
>>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: [hidden email]
>>>>> For additional commands, e-mail: [hidden email]
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Hippo's patch for wicket ids

Bernhard Michal
 
Works for me, your xpath must be wrong. Your syntax is ok. Either there
is no <a> element (link) with attribute
wicketpath="tablePanel_leftList_tableList_pojoList_18_nameCell_namePanel
Link_name" or there is no div tag inside an <a> element...


-----Original Message-----
From: Douglas Ferguson [mailto:[hidden email]]


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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Hippo's patch for wicket ids

Berry van Halderen-2
In reply to this post by Per Lundholm
On Thu, Oct 15, 2009 at 1:14 PM, Per Lundholm <[hidden email]> 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: [hidden email]
For additional commands, e-mail: [hidden email]