[jboss-cvs] JBoss Profiler SVN: r568 - in branches/JBossProfiler2/src/main: www and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Oct 27 21:15:35 EDT 2009


Author: jesper.pedersen
Date: 2009-10-27 21:15:35 -0400 (Tue, 27 Oct 2009)
New Revision: 568

Modified:
   branches/JBossProfiler2/src/main/org/jboss/profiler/client/web/BasicOptBean.java
   branches/JBossProfiler2/src/main/www/setup.xhtml
Log:
[JBPROFILER-96] setup.xhtml connection test

Modified: branches/JBossProfiler2/src/main/org/jboss/profiler/client/web/BasicOptBean.java
===================================================================
--- branches/JBossProfiler2/src/main/org/jboss/profiler/client/web/BasicOptBean.java	2009-10-27 17:20:55 UTC (rev 567)
+++ branches/JBossProfiler2/src/main/org/jboss/profiler/client/web/BasicOptBean.java	2009-10-28 01:15:35 UTC (rev 568)
@@ -33,7 +33,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.faces.event.ValueChangeEvent;
 import javax.faces.model.SelectItem;
 
 /**
@@ -81,7 +80,10 @@
    private org.jboss.remoting.InvokerLocator locator;
 
    private org.jboss.remoting.Client remotingClient;
+   
+   private Boolean connectionSuccessful;
 
+
    /**
     * Get latest opts
     * @return The value
@@ -683,26 +685,32 @@
    }
 
    /**
-    * Connect
-    * @exception Throwable If an error occurs
+    * Test the connection settings
     */
-   public void connect() throws Throwable
+   public void connect() 
    {
-      locator = new org.jboss.remoting.InvokerLocator(this.protocol +
-            "://" + this.host + ":" + this.port);
-      org.jboss.remoting.Client remotingClient = new org.jboss.remoting.Client(locator);
-
-      remotingClient.connect();
-      remotingClient.disconnect();
+      try
+      {
+         locator = new org.jboss.remoting.InvokerLocator(this.protocol +
+               "://" + this.host + ":" + this.port);
+         org.jboss.remoting.Client remotingClient = new org.jboss.remoting.Client(locator);
+   
+         remotingClient.connect();
+         remotingClient.disconnect();
+         connectionSuccessful = true;
+      }
+      catch (Throwable e) 
+      {
+         connectionSuccessful = false;
+      }
+      
    }
 
    /**
     * Protocol changed
-    * @param evt The event
     */
-   public void protocolChanged(ValueChangeEvent evt)
+   public void protocolChanged()
    {
-      String protocol = (String)evt.getNewValue();
       if (protocol.endsWith("socket"))
       {
          this.setPort(5400);
@@ -717,5 +725,34 @@
       }
 
       this.setProtocol(protocol);
+      
+      settingsChanged();
    }
+   
+   /**
+    * mark that the settings have changed
+    */
+   public void settingsChanged()
+   {
+      connectionSuccessful = null;
+   }
+   
+   /**
+    * basic getter
+    * @return - indicate that connection is successfull
+    */
+   public Boolean getConnectionSuccessful()
+   {
+      return connectionSuccessful;
+   }
+
+   /**
+    * basic setter
+    * @param connectionSuccessful  indicate that connection is successfull
+    */
+   public void setConnectionSuccessful(Boolean connectionSuccessful)
+   {
+      this.connectionSuccessful = connectionSuccessful;
+   }
+
 }

Modified: branches/JBossProfiler2/src/main/www/setup.xhtml
===================================================================
--- branches/JBossProfiler2/src/main/www/setup.xhtml	2009-10-27 17:20:55 UTC (rev 567)
+++ branches/JBossProfiler2/src/main/www/setup.xhtml	2009-10-28 01:15:35 UTC (rev 568)
@@ -16,7 +16,7 @@
       <rich:panel>
         <a4j:region id="connectRegion">
           <a4j:form id="connectForm" ajaxSubmit="true" rendered="true"> 
-            <a4j:outputPanel layout="block">
+            <a4j:outputPanel layout="block" id="mainPanel">
               <f:facet name="controls">
                 <h:panelGroup>
                   <h:graphicImage value="/images/modal/close.png" style="cursor:pointer" id="hidelink"/>
@@ -32,14 +32,13 @@
                   <h:panelGrid columns="2" width="100%">
                     <h:outputText value="Host"/>
                     <h:inputText id="inputhost" value="#{basicOptBean.host}" size="20">
-                      <a4j:support event="onkeyup" rendered="inputhost"/>
+                      <a4j:support event="onkeyup" reRender="testConnection" action="#{basicOptBean.settingsChanged}"/>
                     </h:inputText>
         	  
                     <h:outputText value="Protocol"/>
                     <a4j:outputPanel id="protocolSelect" ajaxRendered="true">
-                      <h:selectOneMenu value="#{basicOptBean.protocol}" style="width: 200px" valueChangeListener="#{basicOptBean.protocolChanged}"
-                                       label="#{basicOptBean.protocol}">
-                        <a4j:support event="change" reRender="protocolSelect" />   
+                      <h:selectOneMenu value="#{basicOptBean.protocol}" style="width: 200px" label="#{basicOptBean.protocol}">
+                        <a4j:support event="onchange" action="#{basicOptBean.protocolChanged}" reRender="portvalue,testConnection" />   
                         <f:selectItems value="#{basicOptBean.protocols}" /> 			
                       </h:selectOneMenu>
                     </a4j:outputPanel>
@@ -47,14 +46,15 @@
                     <h:outputText value="Port"/>
                     <h:inputText id="portvalue" value="#{basicOptBean.port}" size="20">
                       <f:validateLongRange minimum="1" maximum="65535"></f:validateLongRange>
+                      <a4j:support event="onkeyup" reRender="testConnection" action="#{basicOptBean.settingsChanged}"/>
                     </h:inputText>
-
-                    <a4j:commandButton id="connectbutton" value="Verify setup" action="#{basicOptBean.connect}" onclick="this.disable=true">
-                      <rich:componentControl for="connectPanel" attachTo="connectbutton" operation="hide" event="onclick"/>
-                    </a4j:commandButton>
+					<a4j:outputPanel id="testConnection">
+	                    <a4j:commandButton disabled="#{basicOptBean.connectionSuccessful}" id="connectbutton" value="Verify setup" action="#{basicOptBean.connect}" onclick="this.disable=true" reRender="testConnection"/>
+	                    <br/>
+	                    <h:outputText value="#{basicOptBean.connectionSuccessful?'Connection test successful':'Connection test failed'}" rendered="#{!empty basicOptBean.connectionSuccessful}"/>
+                    </a4j:outputPanel>
                     <br/>
-
-		  </h:panelGrid>
+		  		  </h:panelGrid>
                 </rich:panel>
               </h:panelGroup>
             </a4j:outputPanel>




More information about the jboss-cvs-commits mailing list