Link to a new page

46 views
Skip to first unread message

Metegs

unread,
Feb 16, 2008, 2:08:10 PM2/16/08
to Google Web Toolkit
hi,
I would like to give links to pages but I couldn't found it in gwt and
I am also using gwt designer for eclipse..

I have already visit the page
http://downloads.instantiations.com/DesignerDoc/integration/latest/do...
but my problem still continues..
In that example it opens both pages which I don't actually want. I
would like to have link like if my site is
www.xyz.com -> when I click to a link it will open another page like
www.xyz.com/abc.asp or www.xyz.com/abc.php etc..
how can I do such think?

Peter Blazejewicz

unread,
Feb 16, 2008, 4:43:37 PM2/16/08
to Google Web Toolkit
Hi,

There is no anchor widget in GWT default UI widgets, There is more GWT
centered Hyperlink, which is basically anchro tag but with additional
behavior to provide navigation within application itself (history
feature),
People usually simply use HTML widget to quicly create anchors within
application,

if you are using GWT Designer here is example of anchor widget which
will integrate nicely with GWT Designer "design" view,
It could works as link or as anchor within your application,

class implementation:

package example.project.client;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.HasHTML;
import com.google.gwt.user.client.ui.HasName;
import com.google.gwt.user.client.ui.Widget;

/**
* Basic implementation of raw Anchor <a> widget
* @see http://www.w3schools.com/tags/tag_a.asp
* @author Peter Blazejewicz
*
*/
public class HTMLLink extends Widget implements HasHTML, HasName {
public HTMLLink() {
setElement(DOM.createAnchor());
}

public String getHref() {
return DOM.getElementAttribute(getElement(), "href");
}

public String getHTML() {
return DOM.getInnerHTML(getElement());
}

public String getId() {
return DOM.getElementAttribute(getElement(), "id");
}

public String getName() {
return DOM.getElementAttribute(getElement(), "name");
}

public int getTabIndex() {
return $getTabIndex(getElement());
}

public String getTarget() {
return DOM.getElementAttribute(getElement(), "target");
}

public String getText() {
return DOM.getInnerText(getElement());
}

public void setHref(String href) {
DOM.setElementAttribute(getElement(), "href", href == null ? "" :
href);
}

public void setHTML(String html) {
DOM.setInnerHTML(getElement(), html == null ? "" : html);
}

public void setId(String id) {
DOM.setElementAttribute(getElement(), "id", id == null ? "" : id);
}

public void setName(String name) {
DOM.setElementAttribute(getElement(), "name", name == null ? "" :
name);
}

public void setTabIndex(int index) {
$setTabIndex(getElement(), index);
}

public void setTarget(String target) {
DOM.setElementAttribute(getElement(), "target", target == null ?
""
: target);
}

public void setText(String text) {
DOM.setInnerText(getElement(), text == null ? "" : text);
}

private native int $getTabIndex(Element element)
/*-{
return element.tabIndex;
}-*/;

private native void $setTabIndex(Element element, int index)
/*-{
element.tabIndex = index;
}-*/;
}



here is example usage code (both features implemented):

package example.project.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class AnchorWidgetUsage implements EntryPoint {
public void onModuleLoad() {
RootPanel rootPanel = RootPanel.get();
// create link to GWT group with new browser window target
final HTMLLink googleGroup = new HTMLLink();
rootPanel.add(googleGroup);
googleGroup.setTarget("_blank");
googleGroup.setId("goglegroup");
googleGroup.setHref("http://groups.google.com/group/Google-Web-
Toolkit/topics");
googleGroup.setHTML("Visit google GWT group");
// create named page anchor
final HTMLLink topNamedAnchor = new HTMLLink();
rootPanel.add(topNamedAnchor);
topNamedAnchor.setName("top");
// create named page link to scroll to top of page
final HTMLLink topNamedLink = new HTMLLink();
rootPanel.add(topNamedLink, 0, 700);
topNamedLink.setHref("#top");
topNamedLink.setText("Page top");
}
}


hth,
regards,
Peter

On Feb 16, 8:08 pm, Metegs <meteomer...@gmail.com> wrote:
> hi,
> I would like to give links to pages but I couldn't found it in gwt and
> I am also using gwt designer for eclipse..
>
> I have already visit the pagehttp://downloads.instantiations.com/DesignerDoc/integration/latest/do...
> but my problem still continues..
> In that example it opens both pages which I don't actually want. I
> would like to have link like if my site iswww.xyz.com-> when I click to a link it will open another page likewww.xyz.com/abc.asporwww.xyz.com/abc.phpetc..

Metegs

unread,
Feb 17, 2008, 12:53:49 PM2/17/08
to Google Web Toolkit
as long as I understood from your answer you are still giving link to
another page..
I want to have pages one is entry page and others are other pages of
my website.. imagine as I have index page, and information page. and
my web site adress is www.gwt.com when you type www.gwt.com it will
open www.gwt.com/index page and if you click information button (link)
it must open a new page not new browser or anythink just reopen a new
page and it will be www.gwt.com/information
so how can I do that?
thanks..

On 16 Şubat, 23:43, Peter Blazejewicz <peter.blazejew...@gmail.com>
wrote:
> Hi,
>
> There is no anchor widget in GWT default UI widgets, There is more GWT
> centered Hyperlink, which is basically anchro tag but with additional
> behavior to provide navigation within application itself (history
> feature),
> People usually simply use HTML widget to quicly create anchors within
> application,
>
> if you are using GWT Designer here is example of anchor widget which
> will integrate nicely with GWT Designer "design" view,
> It could works as link or as anchor within your application,
>
> class implementation:
>
> package example.project.client;
>
> import com.google.gwt.user.client.DOM;
> import com.google.gwt.user.client.Element;
> import com.google.gwt.user.client.ui.HasHTML;
> import com.google.gwt.user.client.ui.HasName;
> import com.google.gwt.user.client.ui.Widget;
>
> /**
>  * Basic implementation of raw Anchor <a> widget
>  * @seehttp://www.w3schools.com/tags/tag_a.asp
> > how can I do such think?- Alıntıyı gizle -
>
> - Alıntıyı göster -

Peter Blazejewicz

unread,
Feb 17, 2008, 2:55:12 PM2/17/08
to Google Web Toolkit
hi,

please read linked w3school.com documentation of anchor tag and use
correct "target" property together with href property,
thanks,
Peter

On Feb 17, 6:53 pm, Metegs <meteomer...@gmail.com> wrote:
> as long as I understood from your answer you are still giving link to
> another page..
> I want to have pages one is entry page and others are other pages of
> my website.. imagine as I have index page, and information page. and
> my web site adress iswww.gwt.comwhen you typewww.gwt.comit will
> openwww.gwt.com/indexpage and if you click information button (link)

lvcster

unread,
Mar 6, 2008, 9:14:35 AM3/6/08
to Google Web Toolkit
I also want to open new link with opening new page. Did Alıntıyı
göster find the solution?
thanks in advance.

Peter Blazejewicz wrote:
> hi,
>
> please read linked w3school.com documentation of anchor tag and use
> correct "target" property together with href property,
> thanks,
> Peter
>
> On Feb 17, 6:53 pm, Metegs <meteomer...@gmail.com> wrote:
> > as long as I understood from your answer you are still giving link to
> > another page..
> > I want to have pages one is entry page and others are other pages of
> > my website.. imagine as I have index page, and information page. and
> > my web site adress iswww.gwt.comwhen you typewww.gwt.comit will
> > openwww.gwt.com/indexpage and if you click information button (link)
> > it must open a new page not new browser or anythink just reopen a new
> > page and it will bewww.gwt.com/information
> > so how can I do that?
> > thanks..
> >
> > On 16 �ubat, 23:43, Peter Blazejewicz <peter.blazejew...@gmail.com>
> > > > how can I do such think?- Al�nt�y� gizle -
> >
> > > - Al�nt�y� g�ster -
Reply all
Reply to author
Forward
0 new messages