Author: shane.bryzak(a)jboss.com
Date: 2009-12-02 06:40:36 -0500 (Wed, 02 Dec 2009)
New Revision: 11714
Added:
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/Formal.java
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/RussianHelloAction.java
Modified:
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/CasualHelloAction.java
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/HelloAction.java
modules/trunk/remoting/examples/helloworld/src/main/webapp/helloworld.xhtml
Log:
example enhancements
Modified:
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/CasualHelloAction.java
===================================================================
---
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/CasualHelloAction.java 2009-12-02
09:36:04 UTC (rev 11713)
+++
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/CasualHelloAction.java 2009-12-02
11:40:36 UTC (rev 11714)
@@ -1,8 +1,10 @@
package org.jboss.seam.remoting.examples.helloworld;
+import static org.jboss.seam.remoting.examples.helloworld.Localized.Language.ENGLISH;
+
import org.jboss.seam.remoting.annotations.WebRemote;
-@Casual
+@Casual @Localized(ENGLISH)
public class CasualHelloAction extends HelloAction
{
@WebRemote
Added:
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/Formal.java
===================================================================
---
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/Formal.java
(rev 0)
+++
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/Formal.java 2009-12-02
11:40:36 UTC (rev 11714)
@@ -0,0 +1,17 @@
+package org.jboss.seam.remoting.examples.helloworld;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Retention(RUNTIME)
+@Target(TYPE)
+@Qualifier
+public @interface Formal
+{
+
+}
Modified:
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/HelloAction.java
===================================================================
---
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/HelloAction.java 2009-12-02
09:36:04 UTC (rev 11713)
+++
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/HelloAction.java 2009-12-02
11:40:36 UTC (rev 11714)
@@ -1,10 +1,12 @@
package org.jboss.seam.remoting.examples.helloworld;
+import static org.jboss.seam.remoting.examples.helloworld.Localized.Language.ENGLISH;
+
import javax.enterprise.inject.Default;
import org.jboss.seam.remoting.annotations.WebRemote;
-@Default
+@Default @Formal @Localized(ENGLISH)
public class HelloAction
{
@WebRemote
Added:
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/RussianHelloAction.java
===================================================================
---
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/RussianHelloAction.java
(rev 0)
+++
modules/trunk/remoting/examples/helloworld/src/main/java/org/jboss/seam/remoting/examples/helloworld/RussianHelloAction.java 2009-12-02
11:40:36 UTC (rev 11714)
@@ -0,0 +1,15 @@
+package org.jboss.seam.remoting.examples.helloworld;
+
+import static org.jboss.seam.remoting.examples.helloworld.Localized.Language.RUSSIAN;
+
+import org.jboss.seam.remoting.annotations.WebRemote;
+
+@Formal @Localized(RUSSIAN)
+public class RussianHelloAction extends HelloAction
+{
+ @WebRemote
+ public String sayHello(String name)
+ {
+ return "Zdravstvuite, " + name;
+ }
+}
Modified: modules/trunk/remoting/examples/helloworld/src/main/webapp/helloworld.xhtml
===================================================================
--- modules/trunk/remoting/examples/helloworld/src/main/webapp/helloworld.xhtml 2009-12-02
09:36:04 UTC (rev 11713)
+++ modules/trunk/remoting/examples/helloworld/src/main/webapp/helloworld.xhtml 2009-12-02
11:40:36 UTC (rev 11714)
@@ -15,30 +15,62 @@
<div style="border:1px solid
black;margin:8px;padding:8px;width:360px">
<span style="font-weight:bold">Select bean
qualifiers</span><br/>
- <input id="qualifier_casual"
type="checkbox">Casual</input><br/>
- <input id="qualifier_russian" type="checkbox">Localized
(Russian)</input><br/>
+
+ <form name="qualifiers">
+ <p>
+ Formality:<br/>
+ <input type="radio" name="formality"
value="Casual" checked="yes">Casual</input><br/>
+ <input type="radio" name="formality"
value="Formal">Formal</input><br/>
+ </p>
+
+ <p>
+ Localization:<br/>
+ <input type="radio" name="lang" value="ENGLISH"
checked="yes">Localized (English)</input><br/>
+ <input type="radio" name="lang"
value="RUSSIAN">Localized (Russian)</input>
+ </p>
+ </form>
+
+ <p>
+ Selected qualifiers:<br/>
+ <input id="qualifierValue" readonly="true"
style="width:300px"/>
+ </p>
</div>
<script type="text/javascript"
src="seam/resource/remoting/resource/remote.js"></script>
<script type="text/javascript"
src="seam/resource/remoting/interface.js?org.jboss.seam.remoting.examples.helloworld.HelloAction"></script>
<script type="text/javascript">
- function sayHello() {
+ //<![CDATA[
+
+ function getRadioValue(options)
+ {
+ for (var i = 0; i < options.length; i++)
+ {
+ if (options[i].checked) return options[i].value;
+ }
+ }
+
+ function getQualifiers() {
+ var qualifiers = "@" + getRadioValue(document.qualifiers.formality) +
"," +
+ "@Localized(" + getRadioValue(document.qualifiers.lang) +
")";
+ document.getElementById("qualifierValue").value = qualifiers;
+ return qualifiers;
+ }
+
+ function sayHello() {
+ var qualifiers = getQualifiers();
+
+ // Prompt the user for their name, if they don't enter one then return.
var name = prompt("What is your name?");
if (name == null) return;
+
+ // Define an inline callback function
var callback = function(result) { alert(result); };
- var qualifiers = "";
- if (document.getElementById("qualifier_casual").checked)
- qualifiers += "@Casual";
-
- if (document.getElementById("qualifier_russian").checked)
- {
- if (qualifiers.length > 0) qualifiers += ",";
- qualifiers += "@Localized(RUSSIAN)";
- }
+ // Get a reference to the HelloAction bean and invoke the sayHello() method
+
Seam.Component.create("org.jboss.seam.remoting.examples.helloworld.HelloAction",
qualifiers).sayHello(name, callback);
-
Seam.Component.create("org.jboss.seam.remoting.examples.helloworld.HelloAction",
qualifiers).sayHello(name, callback);
+ // ]]>
}
</script>
Show replies by date