[seam-commits] Seam SVN: r7371 - trunk/examples/wicket/src/web/org/jboss/seam/example/wicket.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue Feb 5 14:57:11 EST 2008


Author: pete.muir at jboss.org
Date: 2008-02-05 14:57:10 -0500 (Tue, 05 Feb 2008)
New Revision: 7371

Modified:
   trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.html
   trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.java
   trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Confirm.java
   trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/FormInputBorder.java
   trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Home.html
   trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Home.java
   trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Hotel.java
   trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.java
   trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Password.java
   trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Register.java
Log:
Tidy up

Modified: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.html
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.html	2008-02-05 19:56:49 UTC (rev 7370)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.html	2008-02-05 19:57:10 UTC (rev 7371)
@@ -11,14 +11,14 @@
 </div>
 
 <div class="section">
-	<div class="entry errors" wicket:id="messages" />
 
 	<div wicket:id="hotelView" />
 	
 	<div style="clear:both"/>
 
 	<form wicket:id="booking">
-	<fieldset>
+		<div class="entry errors" wicket:id="messages" />
+		<fieldset>
 			
 		<div wicket:id="checkinDateBorder">
 			<span wicket:id="checkinDate" />

Modified: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.java	2008-02-05 19:56:49 UTC (rev 7370)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Book.java	2008-02-05 19:57:10 UTC (rev 7371)
@@ -18,6 +18,7 @@
 
 import java.util.Arrays;
 import java.util.List;
+import java.util.Locale;
 
 import org.apache.wicket.Component;
 import org.apache.wicket.PageParameters;
@@ -26,14 +27,19 @@
 import org.apache.wicket.markup.html.WebPage;
 import org.apache.wicket.markup.html.form.DropDownChoice;
 import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.IChoiceRenderer;
 import org.apache.wicket.markup.html.form.RadioChoice;
 import org.apache.wicket.markup.html.form.TextField;
 import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.html.panel.ComponentFeedbackPanel;
 import org.apache.wicket.markup.html.panel.FeedbackPanel;
 import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.util.convert.IConverter;
+import org.apache.wicket.util.convert.converters.BooleanConverter;
 import org.apache.wicket.validation.ValidationError;
 import org.jboss.seam.annotations.In;
 import org.jboss.seam.annotations.security.Restrict;
+import org.jboss.seam.core.Conversation;
 import org.jboss.seam.example.wicket.action.Booking;
 import org.jboss.seam.example.wicket.action.HotelBooking;
 
@@ -42,7 +48,6 @@
 {
    
    private static final List<String> bedOptions = Arrays.asList("One king-sized bed", "Two double beds", "Three beds");
-   private static final List<String> smokingOptions = Arrays.asList("Smoking", "Non Smoking");
    private static final List<String> monthOptions = Arrays.asList("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    private static final List<String> yearOptions = Arrays.asList("2008", "2009");
    
@@ -55,10 +60,8 @@
 	public Book(final PageParameters parameters)
 	{
 	   super(parameters);
-	   System.out.println(parameters);
 	   Template body = new Template("body");
 	   add(body);
-	   body.add(new FeedbackPanel("messages"));
 	   body.add(new HotelViewPanel("hotelView", booking.getHotel()));
 	   body.add(new HotelBookingForm("booking"));
 	   
@@ -70,8 +73,9 @@
       public HotelBookingForm(String id)
       {
          super(id);
-         add(new FormInputBorder("checkinDateBorder", "Check in date", new DateField("checkinDate").setRequired(true), new PropertyModel(booking, "checkinDate")));
-         add(new FormInputBorder("checkoutDateBorder", "Check out date", new DateField("checkoutDate").setRequired(true), new PropertyModel(booking, "checkoutDate")));
+         add(new ComponentFeedbackPanel("messages", this));
+         add(new FormInputBorder("checkinDateBorder", "Check in date", new DateField("checkinDate").setRequired(true), new PropertyModel(booking, "checkinDate"), false));
+         add(new FormInputBorder("checkoutDateBorder", "Check out date", new DateField("checkoutDate").setRequired(true), new PropertyModel(booking, "checkoutDate"), false));
          add(new FormInputBorder("bedsBorder", "Room Preference", new DropDownChoice("beds", bedOptions)
          {
             @Override
@@ -81,23 +85,34 @@
             }
             
          }.setRequired(true), new PropertyModel(booking, "beds")));
-         add(new FormInputBorder("smokingBorder", "Smoking Preference", new RadioChoice("smoking", smokingOptions)
+         add(new FormInputBorder("smokingBorder", "Smoking Preference", new RadioChoice("smoking", Arrays.asList(new Boolean[] {true, false}), new IChoiceRenderer()
          {
-            
-            @Override
-            protected Object convertChoiceIdToChoice(String id)
+
+            public Object getDisplayValue(Object object)
             {
-               if ("Smoking".equals(id))
+               if (new Boolean(true).equals(object))
                {
-                  return true;
+                  return "Smoking";
                }
                else
                {
-                  return false;
+                  return "Non Smoking";
                }
             }
+
+            public String getIdValue(Object object, int index)
+            {
+               if (new Boolean(true).equals(object))
+               {
+                  return "true";
+               }
+               else
+               {
+                  return "false";
+               }
+            }
             
-         }.setRequired(true), new PropertyModel(booking, "smoking")));
+         }), new PropertyModel(booking, "smoking"), false));
          add(new FormInputBorder("creditCardBorder", "Credit Card #", new TextField("creditCard").setRequired(true), new PropertyModel(booking, "creditCard")));
          add(new FormInputBorder("creditCardNameBorder", "Credit Card Name", new TextField("creditCardName").setRequired(true), new PropertyModel(booking, "creditCardName")));
          add(new FormInputBorder("creditCardExpiryBorder", "Credit Card Expiry", new DropDownChoice("creditCardExpiryMonth", monthOptions).setRequired(true), new PropertyModel(booking, "creditCardExpiryMonth")).add(new DropDownChoice("creditCardExpiryYear", yearOptions).setRequired(true), new PropertyModel(booking, "creditCardExpiryYear")));
@@ -136,5 +151,12 @@
          return super.add(behavior);
       }
 	   
-	}	
+	}
+	
+	@Override
+	protected void onBeforeRender()
+	{
+	   super.onBeforeRender();
+	   System.out.println("cid " + Conversation.instance().getId());
+	}
 }

Modified: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Confirm.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Confirm.java	2008-02-05 19:56:49 UTC (rev 7370)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Confirm.java	2008-02-05 19:57:10 UTC (rev 7371)
@@ -8,14 +8,12 @@
 import org.apache.wicket.PageParameters;
 import org.apache.wicket.markup.html.WebPage;
 import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.link.Link;
 import org.jboss.seam.annotations.In;
 import org.jboss.seam.annotations.security.Restrict;
 import org.jboss.seam.core.Conversation;
-import org.jboss.seam.core.ConversationPropagation;
-import org.jboss.seam.core.Manager;
 import org.jboss.seam.example.wicket.action.Booking;
 import org.jboss.seam.example.wicket.action.HotelBooking;
+import org.jboss.seam.wicket.SeamLink;
 
 @Restrict
 public class Confirm extends WebPage 
@@ -31,35 +29,30 @@
 	{
 	   super(parameters);
 	   Template body = new Template("body");
-	   final String cid = Conversation.instance().getId();
 	   body.add(new HotelViewPanel("hotel", booking.getHotel()));
 	   body.add(new OutputBorder("totalBorder", "Total Payment", new Label("total", DecimalFormat.getCurrencyInstance(Locale.US).format(booking.getTotal()))));
-	   body.add(new OutputBorder("checkinDateBorder", "Check in", new Label("checkinDate", new SimpleDateFormat("mm/dd/yy").format(booking.getCheckinDate()))));
-	   body.add(new OutputBorder("checkoutDateBorder", "Check out", new Label("checkoutDate", new SimpleDateFormat("mm/dd/yy").format(booking.getCheckoutDate()))));
+	   body.add(new OutputBorder("checkinDateBorder", "Check in", new Label("checkinDate", new SimpleDateFormat().format(booking.getCheckinDate()))));
+	   body.add(new OutputBorder("checkoutDateBorder", "Check out", new Label("checkoutDate", new SimpleDateFormat().format(booking.getCheckoutDate()))));
 	   body.add(new OutputBorder("creditCardNumberBorder", "Credit Card #", new Label("creditCardNumber", booking.getCreditCard())));
-	   body.add(new Link("revise")
+	   body.add(new SeamLink("revise")
       {
          @Override
          public void onClick()
          {
-            ConversationPropagation.instance().setConversationId(cid);
-            Manager.instance().restoreConversation();
             hotelBooking.bookHotel();
             setResponsePage(Book.class);
          }
       });
-      body.add(new Link("confirm")
+      body.add(new SeamLink("confirm")
       {
          @Override
          public void onClick()
          {
-            ConversationPropagation.instance().setConversationId(cid);
-            Manager.instance().restoreConversation();
             hotelBooking.confirm();
             setResponsePage(Main.class);
          }
       });
-      body.add(new Link("cancel")
+      body.add(new SeamLink("cancel")
       {
          @Override
          public void onClick()
@@ -73,4 +66,11 @@
 	   add(body);
 	}
 	
+	@Override
+   protected void onBeforeRender()
+   {
+	   super.onBeforeRender();
+      System.out.println("cid " + Conversation.instance().getId());
+   }
+	
 }

Modified: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/FormInputBorder.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/FormInputBorder.java	2008-02-05 19:56:49 UTC (rev 7370)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/FormInputBorder.java	2008-02-05 19:57:10 UTC (rev 7371)
@@ -30,7 +30,7 @@
    private ComponentFeedbackPanel feedbackPanel;
    
    /**
-    * Create a new form input border
+    * Create a new form input border which validates using ajax
     * @param id Id of border component on page
     * @param label Label to add
     * @param component The component to wrap
@@ -38,6 +38,19 @@
     */
    public FormInputBorder(String id, String label, FormComponent component, PropertyModel model)
    {
+      this(id, label, component, model, true);
+   }
+   
+   /**
+    * Create a new form input border which validates
+    * @param id Id of border component on page
+    * @param label Label to add
+    * @param component The component to wrap
+    * @param model The model to attach the component to
+    * @param ajax Whether to use ajax validation
+    */
+   public FormInputBorder(String id, String label, FormComponent component, PropertyModel model, boolean ajaxValidate)
+   {
       super(id);
       component.setLabel(new Model(label));
       if (component.isRequired())
@@ -52,33 +65,37 @@
       add(labelComponent);
       add(component, model);
       feedbackPanel = new ComponentFeedbackPanel("message", component);
-      feedbackPanel.setOutputMarkupId(true);
+      
       add(feedbackPanel);
       component.add(new ModelValidator(model));
       
-      component.add(new AjaxFormComponentUpdatingBehavior("onblur")
+      if (ajaxValidate)
       {
-
-         @Override
-         protected void onUpdate(AjaxRequestTarget target)
+         feedbackPanel.setOutputMarkupId(true);
+         component.add(new AjaxFormComponentUpdatingBehavior("onblur")
          {
-            getFormComponent().validate();
-            target.addComponent(feedbackPanel);
-         }
-         
-         @Override
-         protected void onError(AjaxRequestTarget target, RuntimeException e)
-         {
-            target.addComponent(feedbackPanel);
-         }
-         
-         @Override
-         protected boolean getUpdateModel()
-         {
-            return true;
-         }
-         
-      });
+   
+            @Override
+            protected void onUpdate(AjaxRequestTarget target)
+            {
+               getFormComponent().validate();
+               target.addComponent(feedbackPanel);
+            }
+            
+            @Override
+            protected void onError(AjaxRequestTarget target, RuntimeException e)
+            {
+               target.addComponent(feedbackPanel);
+            }
+            
+            @Override
+            protected boolean getUpdateModel()
+            {
+               return true;
+            }
+            
+         });
+      }
    }
    
    public FormInputBorder add(FormComponent component, PropertyModel model)

Modified: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Home.html
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Home.html	2008-02-05 19:56:49 UTC (rev 7370)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Home.html	2008-02-05 19:57:10 UTC (rev 7371)
@@ -39,9 +39,7 @@
 			    <p>
 			       This sample application demonstrates how easy it is to develop stateful web 
 			       applications using JBoss Seam. Just register, login, and book a room to see 
-			       Seam in action. Throughout the application you'll see popup links like 
-			       the ones at the bottom of this page. Click them to see how the application 
-			       works under the hood.
+			       Seam with Wicket in action.
                 </p>
 			    
 			    <p>

Modified: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Home.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Home.java	2008-02-05 19:56:49 UTC (rev 7370)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Home.java	2008-02-05 19:57:10 UTC (rev 7371)
@@ -70,7 +70,7 @@
          }
          catch (LoginException e)
          {
-            error(new ValidationError().setMessage("Login failed"));
+            error("Login failed");
             log.error("Login failed", e);
          }
       }

Modified: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Hotel.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Hotel.java	2008-02-05 19:56:49 UTC (rev 7370)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Hotel.java	2008-02-05 19:57:10 UTC (rev 7371)
@@ -31,7 +31,7 @@
 	         setResponsePage(Book.class);
 	      }
 	   });
-	   body.add(new Link("cancel")
+	   body.add(new SeamLink("cancel")
       {
          @Override
          public void onClick()

Modified: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.java	2008-02-05 19:56:49 UTC (rev 7370)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Main.java	2008-02-05 19:57:10 UTC (rev 7371)
@@ -33,6 +33,7 @@
 import org.apache.wicket.markup.html.link.BookmarkablePageLink;
 import org.apache.wicket.markup.html.link.Link;
 import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
+import org.apache.wicket.markup.html.panel.ComponentFeedbackPanel;
 import org.apache.wicket.markup.html.panel.FeedbackPanel;
 import org.apache.wicket.markup.repeater.Item;
 import org.apache.wicket.markup.repeater.data.DataView;
@@ -223,7 +224,7 @@
          add(new TextField("searchString", new PropertyModel(hotelSearch, "searchString")));
          List<Integer> pageSizes = Arrays.asList(new Integer[] { 5, 10, 20 });
          add(new DropDownChoice("pageSize", new PropertyModel(this, "pageSize"), pageSizes));
-         final Component messages = new FeedbackPanel("messages").setOutputMarkupId(true); 
+         final Component messages = new ComponentFeedbackPanel("messages", this).setOutputMarkupId(true); 
          add(messages);
          add(new IndicatingAjaxButton("submit", this)
          {

Modified: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Password.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Password.java	2008-02-05 19:56:49 UTC (rev 7370)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Password.java	2008-02-05 19:57:10 UTC (rev 7371)
@@ -6,6 +6,7 @@
 import org.apache.wicket.markup.html.form.PasswordTextField;
 import org.apache.wicket.markup.html.form.validation.EqualInputValidator;
 import org.apache.wicket.markup.html.link.PageLink;
+import org.apache.wicket.markup.html.panel.ComponentFeedbackPanel;
 import org.apache.wicket.markup.html.panel.FeedbackPanel;
 import org.apache.wicket.model.PropertyModel;
 import org.jboss.seam.annotations.In;
@@ -54,7 +55,7 @@
          FormComponent verify = new PasswordTextField("verify").setRequired(true);
          add(new FormInputBorder("passwordBorder", "Password", password , new PropertyModel(user, "password")));
          add(new FormInputBorder("verifyBorder", "Verify Password", verify, new PropertyModel(this, "verify")));
-         add(new FeedbackPanel("messages"));
+         add(new ComponentFeedbackPanel("messages", this));
          add(new EqualInputValidator(password, verify));
       }
       

Modified: trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Register.java
===================================================================
--- trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Register.java	2008-02-05 19:56:49 UTC (rev 7370)
+++ trunk/examples/wicket/src/web/org/jboss/seam/example/wicket/Register.java	2008-02-05 19:57:10 UTC (rev 7371)
@@ -5,9 +5,9 @@
 import org.apache.wicket.markup.html.form.FormComponent;
 import org.apache.wicket.markup.html.form.PasswordTextField;
 import org.apache.wicket.markup.html.form.TextField;
-import org.apache.wicket.markup.html.form.validation.EqualInputValidator;
+import org.apache.wicket.markup.html.form.validation.EqualPasswordInputValidator;
 import org.apache.wicket.markup.html.link.PageLink;
-import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.markup.html.panel.ComponentFeedbackPanel;
 import org.apache.wicket.model.PropertyModel;
 import org.jboss.seam.annotations.In;
 import org.jboss.seam.example.wicket.action.User;
@@ -44,8 +44,8 @@
          FormComponent verify = new PasswordTextField("verify").setRequired(true);
          add(new FormInputBorder("passwordDecorate", "Password", password , new PropertyModel(user, "password")));
          add(new FormInputBorder("verifyDecorate", "Verify Password", verify, new PropertyModel(register, "verify")));
-         add(new FeedbackPanel("messages"));
-         add(new EqualInputValidator(password, verify));
+         add(new ComponentFeedbackPanel("messages", this));
+         add(new EqualPasswordInputValidator(password, verify));
       }
       
       @Override




More information about the seam-commits mailing list