override / overrule a gwt class, AbstractPlaceHistoryMapper

55 views
Skip to first unread message

pansen

unread,
Jul 20, 2011, 11:58:19 AM7/20/11
to Google Web Toolkit
hi all,

i try to bring in our project a slightliy modified version of the
class ``com.google.gwt.place.impl.AbstractPlaceHistoryMapper<F>``.
unfortunately without success.

it seems like deferred binding does not work here as this is not a
client class. or it does not work cause its an abstract class - i
couldn't manage it.

now my trivial solution (/try) was to have the same file in the same
package in my project and hope this would be chosen before the
gwt*.jar file. unfortunately this is not the case and not working...

has anyone a hint for me how to bring in my minimal modified version
of this file?

btw. this problem belongs to this thread
http://groups.google.com/group/google-web-toolkit/browse_thread/thread/33f8c5e63209da4f,
which i will write a blog entry when its done. but this part is the
very last problem...

cheers, andi

Jeff Larsen

unread,
Jul 20, 2011, 12:13:41 PM7/20/11
to google-we...@googlegroups.com
if you look at Place.gwt.xml you'll see that 


  <generate-with class="com.google.gwt.place.rebind.PlaceHistoryMapperGenerator">
    <when-type-assignable class="com.google.gwt.place.shared.PlaceHistoryMapper"/>
  </generate-with>

so the class you need to override is PlaceHistoryMapperGenerator

Looking in PlaceHistoryMapperGenerator you'll see imports for 

import com.google.gwt.place.impl.AbstractPlaceHistoryMapper;
import com.google.gwt.place.impl.AbstractPlaceHistoryMapper.PrefixAndToken;

If you did a copy/paste of the code and imported your class extending APHM and the PrefixAndToken(possibly) and then in your gwt.xml file did   <generate-with class="com.my.generator.CopiedPlaceHistoryMapperGenerator">
    <when-type-assignable class="com.google.gwt.place.shared.PlaceHistoryMapper"/>
  </generate-with>

you should get the result you desire. 

pansen

unread,
Jul 20, 2011, 12:28:17 PM7/20/11
to Google Web Toolkit
harrr...

its working via the "put my own version to the classpath". we have
several subprojects and i did it in the wrong one :)

thanks, i'm happy ;)

On 20 Jul., 17:58, pansen <andi.ba...@googlemail.com> wrote:
> hi all,
>
> i try to bring in our project a slightliy modified version of the
> class ``com.google.gwt.place.impl.AbstractPlaceHistoryMapper<F>``.
> unfortunately without success.
>
> it seems like deferred binding does not work here as this is not a
> client class. or it does not work cause its an abstract class - i
> couldn't manage it.
>
> now my trivial solution (/try) was to have the same file in the same
> package in my project and hope this would be chosen before the
> gwt*.jar file. unfortunately this is not the case and not working...
>
> has anyone a hint for me how to bring in my minimal modified version
> of this file?
>
> btw. this problem belongs to this threadhttp://groups.google.com/group/google-web-toolkit/browse_thread/threa...,

pansen

unread,
Jul 20, 2011, 2:08:40 PM7/20/11
to Google Web Toolkit
jeff,

again - thank you for your answer; this solution looks very clean. i
figured out all that stuff too, but i didn't have the correct
classnames to apply. your hint, looking at ``Place.gwt.xml`` is very
helpful though.

finally i didn't change it to your solution just because i don't have
to copy that much files (only one) and there is no need to inherit a
custom ``*.gwt.xml`` or write it to any of ours.

for the record: our solution will only work flawlessly if you use
maven 3.x. we had classpath issues with maven 2.x versions as the
classpath was built in a different order on linux than on osx for
example.

cheers, andi

Jeff Larsen

unread,
Jul 20, 2011, 2:24:54 PM7/20/11
to google-we...@googlegroups.com
Naw, the solution is pretty ugly, copy/pasting code sucks. It has the advantage of working quickly. Sounds like you got a better solution, so I'd definitely roll with that. The only caveat is that you'll have to be careful with GWT version updates now, there are no guarentees that the class you're extending won't change and they won't tell you. 
Reply all
Reply to author
Forward
0 new messages