01: package hugetestportlet;
02:
03: import java.awt.event.ActionEvent;
04: import java.awt.event.ActionListener;
05:
06: import org.wings.SButton;
07: import org.wings.SForm;
08: import org.wings.SFrame;
09: import org.wings.SGridLayout;
10: import org.wings.SLabel;
11: import org.wings.SPortletAnchor;
12: import org.wings.STextField;
13: import org.wings.event.SRenderEvent;
14: import org.wings.event.SRenderListener;
15: import org.wings.portlet.PortletParameterEvent;
16: import org.wings.portlet.PortletParameterListener;
17: import org.wings.portlet.PortletParameterProvider;
18:
19: public class HugeTestPortletWingS {
20:
21: public HugeTestPortletWingS() {
22:
23: SGridLayout gridLayout = new SGridLayout(1);
24: SForm panel = new SForm(gridLayout);
25: SButton submitButton = new SButton("Submit");
26: gridLayout.setVgap(10);
27:
28: final SLabel message = new SLabel();
29: final STextField textField = new STextField();
30:
31: submitButton.addActionListener(new ActionListener() {
32: public void actionPerformed(ActionEvent e) {
33: message.setText("Hallo " + textField.getText() + " !");
34: }
35: });
36:
37: panel.add(new SLabel("Please insert name:"));
38: panel.add(textField);
39: panel.add(submitButton);
40: panel.add(message);
41:
42: SPortletAnchor editMode = new SPortletAnchor(
43: SPortletAnchor.ACTION_URL, SPortletAnchor.EDIT_MODE);
44: editMode.add(new SLabel("go to edit mode"));
45:
46: panel.add(editMode);
47:
48: final SLabel paramLabel = new SLabel();
49:
50: PortletParameterProvider ppp = PortletParameterProvider
51: .getInstance();
52: ppp.addPortletParameterListener(new PortletParameterListener() {
53:
54: public void newPortletParameters(PortletParameterEvent e) {
55:
56: String[] param = e.getParameterValues("testprop");
57: if (param != null) {
58: paramLabel.setText("param: " + param[0]);
59: } else {
60: paramLabel.setText("param is null");
61: }
62:
63: }
64:
65: });
66:
67: panel.add(paramLabel);
68:
69: SFrame rootFrame = new SFrame();
70: rootFrame.getContentPane().add(panel);
71: rootFrame.setVisible(true);
72:
73: }
74:
75: }
|