Wiki source code of Development-Examples-Anchors

Last modified by Pascal Robert on 2010/09/13 00:31

Hide last authors
smmccraw 1.1 1 Put the following in the superclass for your components:
2
Pascal Robert 3.1 3 {{code}}
smmccraw 1.1 4
5 private String anchor;
Pascal Robert 3.1 6
smmccraw 1.1 7 public void appendToResponse(WOResponse response, WOContext context) {
Pascal Robert 3.1 8
smmccraw 1.1 9 if (anchor != null) {
10 response.setHeader(context.componentActionURL() + "#" + anchor, "location");
11 response.setHeader("text/html", "content-type");
12 response.setHeader("0", "content-length");
13 response.setStatus(302);
14 anchor = null;
15 } else {
16 super.appendToResponse(response, context);
17 }
18 } // appendToResponse
Pascal Robert 3.1 19
smmccraw 1.1 20 public String getAnchor() {
21 return anchor;
22 }
23 public void setAnchor(String s) {
24 anchor = s;
25 }
26
27
Pascal Robert 3.1 28 {{/code}}
29
smmccraw 1.1 30 In the component where we want to use an anchor you just put in
31
Pascal Robert 3.1 32 {{code}}
smmccraw 1.1 33
Pascal Robert 3.1 34 <a name="myanchor"></a>
smmccraw 1.1 35
Pascal Robert 3.1 36 {{/code}}
smmccraw 1.1 37
Pascal Robert 5.1 38 and something like the following in the code where we want to jump to this anchor:
smmccraw 1.1 39
Pascal Robert 3.1 40 {{code}}
smmccraw 1.1 41
Pascal Robert 3.1 42 protected WOComponent doSometingAndJumpToAnchor() {
43 // do something :)
44 setAnchor("myanchor");
45 return null;
46 }
smmccraw 1.1 47
Pascal Robert 3.1 48 {{/code}}