It works great, so I'm in debt with you, than you !!

Only a little enhacement on code

public Widget createAnchorWidget(String name) throws Exception {
                if (!anchors.containsKey(name)) {
                        Image im =  new Image("pixel.gif"); // really
should use image bundle
                        anchors.put(name,im);
                         return im
                }

Oskar

On 24 dic 2008, 22:34, "[email protected]" <[email protected]>
wrote:
> OK, I whipped this up for you. It should get you close to what you
> want to do. The downside will be that you may have to have a 'visible'
> widget (in this case a transparent image) to anchor.
>
> import java.util.HashMap;
>
> import com.google.gwt.user.client.DOM;
> import com.google.gwt.user.client.ui.ClickListener;
> import com.google.gwt.user.client.ui.Image;
> import com.google.gwt.user.client.ui.Label;
> import com.google.gwt.user.client.ui.Widget;
>
> public class AnchorManager {
>
>         private HashMap<String, Widget> anchors = new HashMap<String, Widget>
> ();
>
>         public Widget createLink(String text, final String anchorName) {
>                 Label lbl = new Label(text);
>                 lbl.addClickListener(new ClickListener() {
>                         public void onClick(Widget sender) {
>                                 try {
>                                         showAnchor(anchorName);
>                                 } catch (Exception e) {
>                                         // TODO: handle Exception
>                                 }
>                         }
>                 });
>                 return lbl;
>         }
>
>         public Widget createAnchorWidget(String name) throws Exception {
>                 if (!anchors.containsKey(name)) {
>                         return new Image("pixel.gif"); // really should use 
> image bundle
>                 } else {
>                         throw new Exception("Anchor already exists");
>                 }
>         }
>
>         public void showAnchor(String name) throws Exception {
>                 if (anchors.containsKey(name)) {
>                         DOM.scrollIntoView(anchors.get(name).getElement());
>                 } else {
>                         throw new Exception("Anchor does not exists");
>                 }
>         }
>
> }
>
> On Dec 23, 1:02 pm, obesga <[email protected]> wrote:
>
> > I've trying to implement internal anchors in GWT ( to make an index
> > into a loooong page), but there's a problem with IE that makes the
> > whole page to get reloaded.
> > As far as I've been searching in forums, the problem is not resolved
> > so 
> > thishttp://groups.google.com/group/Google-Web-Toolkit/browse_thread/threa......
>
> >http://code.google.com/p/google-web-toolkit/issues/detail?id=2152
>
> > ¿ Is there another way to implement or emulate the internal linking of
> > a document in GWT ?
> > Perhaps with ScrollPanel.setScrollPosition(); ¿ anyone has tried, can
> > give me some indication on how to start ?
>
> > Thank you
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to