1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.custom.autoscroll;
20
21 import javax.faces.application.ResourceDependency;
22 import javax.faces.component.behavior.ClientBehaviorBase;
23 import javax.faces.component.behavior.ClientBehaviorContext;
24
25 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFBehavior;
26 import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
27 import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
28 import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
29 import org.apache.myfaces.shared_tomahawk.renderkit.html.util.FormInfo;
30
31
32
33
34
35
36
37
38 @JSFBehavior(name="t:autoScroll",bodyContent="empty")
39 @ResourceDependency(library="org.apache.myfaces", name="oamSubmit.js")
40 public class AutoscrollBehavior extends ClientBehaviorBase
41 {
42
43 public static final String BEHAVIOR_ID = "org.apache.myfaces.custom.autoscroll.AutoscrollBehavior";
44
45 @Override
46 public String getScript(ClientBehaviorContext behaviorContext)
47 {
48 FormInfo nestedFormInfo = RendererUtils.findNestingForm(behaviorContext.getComponent(), behaviorContext.getFacesContext());
49 StringBuilder script = new StringBuilder();
50 HtmlRendererUtils.appendAutoScrollAssignment(behaviorContext.getFacesContext(), script, nestedFormInfo.getFormName());
51 return script.toString();
52 }
53
54
55
56
57
58
59 @JSFProperty
60 private String getEvent()
61 {
62 return null;
63 }
64 }