Scrum

Keywords:

Filed Under:

Creating Your First Web Flow

original link: https://fisheye.springsource.org/browse/~raw,r=16/spring-samples/tutorials/getting-started-with-spring-webflow/yourFirstFlow.html 

http://static.springsource.com/projects/tc-server/6.0/getstart/tgsdevtut.html 

Creating Your First Web Flow

Create your project

  1. Download the Eclipse IDE for Spring Developers, called the SpringSource Tool Suite (STS). After downloading completes, extract the archive to your directory of choice.
  2. Open STS and access File -> New -> Other... -> SpringSource Tool Suite -> Template Project. Select "Web Flow Project" and enter helloworld for your project name. Select the Embedded Apache Tomcat as your project's targeted server runtime. Finish the new project wizard.
  3. Next, right-click on your project in your Package Explorer view, and select Run On Server. You should see your application's welcome page appear in the embedded web browser. Alternatively, you can access your application in an external browser such as Firefox at http://localhost:8080/helloworld
  1. TODO

Create your first helloworld flow

  1. Create a new directory for your flow inside /src/main/webapp/WEB-INF; name the directory helloworld. Right-click on the directory and access New -> Spring Web Flow Definition. Enter the filename helloworld-flow.xml and finish. The flow definition will be generated for you with an initial view-state named start.
  2. Go ahead and create a start.jsp in your flow directory and paste in the following:
    			    <html>	        <head>	            <title>Hello world!</title>	        </head>	        <h1>Hello world!</h1>	    </html>		
    	
  3. From the Servers view, restart your server, then startup your flow by accessing http://localhost:8080/getting-started-with-spring-webflow/app/helloworld. You should see your Hello world! message display. Note you only have to restart your server when you add new flows to the system. When you change flows, changes will be refreshed automatically.

Add a page navigation rule

  1. Next, try transitioning your flow from one state to another to implement a navigation rule. In your helloworld flow, add the following transition to your start view-state:
    	<transition on="submit" to="page2" />    								
    	
    Then define your page2 view-state:
    		    <view-state id="page2">	    </view-state>	
    	
    And the corresponding page2.jsp:
    		    <html>	        <head>	            <title>Hello world!</title>	        </head>	        <h1>This is page 2!</h1>	    </html>		
    	
    Finally, create a button on your start.jsp that raises the submit event to trigger the state transition:
    		    <form method="post">	        <input type="submit" name="_eventId_submit" value="Submit" />	    </form>	
    	
    Click the button and you should be taken to page 2.

Add a dynamic page navigation rule

Web flow excels at implementing dynamic navigation logic that takes a user through different paths based on what they enter or who they are.

  1. Try implementing a dynamic navigation rule by first adding a bound checkbox to your start.jsp. Do this by replacing its contents with the following snippet:
    		    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>	    <html>	        <head>	            <title>Hello world!</title>	        </head>	        <h1>Hello world!</h1>	        <form:form method="post" modelAttribute="helloWorldForm">	            <form:checkbox path="selected" />	            <input type="submit" name="_eventId_submit" value="Submit" />	        </form:form>  	    </html>	
    	
  2. Next, create a HelloWorldForm class in the org.springframework.webflow.samples.helloworld package with the following code:
    		    package org.springframework.webflow.samples.helloworld;	  	    import java.io.Serializable;	  	    public class HelloWorldForm implements Serializable {	        private boolean selected = true;	        	        public boolean isSelected() {	            return selected;	        }	        	        public void setSelected(boolean selected) {	            this.selected = selected;	        }	    }	
    	
  3. At the top of your helloworld-flow, declare the HelloWorldForm as a flow variable:
    	<var name="helloWorldForm" class="org.springframework.webflow.samples.helloworld.HelloWorldForm" />    								
    	
    Then update your start view-state to use this variable as its data model, enabling automatic model binding and validation:
    	<view-state id="start" model="helloWorldForm"> ...    									
    	

    Refresh your flow and the checkbox should render checked since the default value for the HelloWorldForm selected property is true. Uncheck the box and submit and go back in your browser and the unchecked status should be preserved.

  4. Now insert a decision state that says if the checkbox is selected goto page2, else goto a new page3:
    		    <decision-state id="isSelected">	        <if test="helloWorldForm.selected" then="page2" else="page3" />	    </decision-state>	 	    <view-state id="page2">	    </view-state> 	     	    <view-state id="page3">	    </view-state>	
    	
    Be sure to update your start view-state to transition to the isSelected decision state instead of page2 directly:
    		    <view-state id="start">	        <transition on="submit" to="isSelected" />	    </view-state>	
    	
    Click the Submit button with the checkbox selected and you should be taken to page2. Click the button with the checkbox de-selected and you should be taken to page3 (you'll need to create a JSP or you'll get a 404).

Finish your helloworld flow

  1. Finish up your helloworld flow by adding another button on the start.jsp that ends the flow:
    	<input type="submit" name="_eventId_finish" value="Finish" />    								
    	
    In your start view-state, declare the finish transition:
    	<transition on="finish" to="finished" />    								
    	
    And finally define the end-state:
    	<end-state id="finished" view="externalRedirect:welcome" />    								
    	
    Click the Finish button and you should be taken back to the application welcome screen.

Visualize the flow

  1. In your IDE, navigate to your helloworld-flow.xml in the Spring Explorer view, or within the Spring Elements node of the Project Explorer view. Right-click on the file and select Open Graphical Editor. Your graph should look similar to the visualization below:

Keywords:

Filed Under:

MySQL downloads

Keywords:

Filed Under: Infrastructure · MySQL

Spring IDE setup

Follow these steps to install java: QBW Install-java

 

Download and install Spring STS :Ecliples with Spring plugin: http://www.springsource.com/products/springsource-download-center

I downloaded: springsource-tool-suite-2.2.0.RELEASE-e3.5.1-win32-installer.exe (231.00 mb)

No need to install:

  • tcServer
  • dmServer

 

Once the installation is completed: get the latest updates.

(Remember to restart after each update)

Click Help, Check for updates.

Goto HELP -> STS Dashboard.

Install EclEmma (CodeCoverage) from the Extensions tab.

Install Apache Tomcat from the Configuration tab. (Tomcat will be installed in the root of Springsource.)

 

Don't forget the updates to STS.

Goto HELP -> Install new software.

Just in case you did not save it as a link:

STS welcome: http://www.springsource.com/products/sts/welcome?version=2.2.0.RELEASE&os=win32

==============================================

You will also need the Spring JARs, as they are not included in the IDE.

Here is the Spring IDE software links: http://www.springsource.com/download/community

I downloaded version 3.0 here: spring-framework-3.0.0.RELEASE.zip (21.15 mb)

 

 

Let's give it a shot with our: Spring-Hello-World

 

Keywords:

Filed Under: Infrastructure · Spring

Active MQ - Windows-NT Service

Here are the steps to install the ActiveMQ broker as an NT service:

  1. After download, Go to ACTIVEMQ_HOME/bin/win32
  2. Run InstallService.bat
  3. Modify bin/win32/wrapper.conf.  Update ../.. and .. to physical path. (May not be needed except on VISTA).
  4. Modify C:\Users\DavidQ\Apache\ActiveMQ\apache-activemq-5.2.0\bin\win32\wrapper.conf
  5. # Log file to use for wrapper output logging.

    ## daq wrapper.logfile=%ACTIVEMQ_BASE%/data/wrapper.log

    wrapper.logfile=C:/Users/DavidQ/Apache/ActiveMQ/wrapper.log

  6. Modify C:\Users\DavidQ\Apache\ActiveMQ\apache-activemq-5.2.0\conf\log4j.properties
  7. # File appender 

    #daq log4j.appender.out.file=${activemq.base}/data/activemq.log

    log4j.appender.out.file=C:/Users/DavidQ/Apache/ActiveMQ/activemq.log

 

After runinng InstallService.bat, the ActiveMQ service should be added to the list of NT services. It is not started by default.

To verify, go to control panel -> administrative tools -> services and look for the ActiveMQ service. Here you can start the ActiveMQ service or configure it to start automatically every time the system boots.

To administer, navigate to http://localhost:8161/admin/ 

To remove the ActiveMQ service:

  1. Stop the service from running. 
  2. Run UninstallService.bat

 

 

Keywords:

Filed Under: Active MQ

Active MQ - setup

Good step by step  http://activemq.apache.org/getting-started.html

sample code: AMQinA-src.zip (223.76 kb)

 

 

To start you will need JAVA installed. You should be able to get that at: http://www.java.com/en/download/. 

The main thing you'll want to double check is the environment variable JAVA_HOME. It should point to the directory where Java was installed. Additionally, make sure %JAVA_HOME%\bin is in your PATH. 

Now download ActiveMQ code, which is at http://activemq.apache.org/download.html. Currently using 4.1.1, so download that version.

Once apache-activemq-4.1.1.zip is downloaded, unzip to any directory (I put it in C:\Program Files\apache-activemq-4.1.1\).

You can start Active MQ by running from C:\Program Files\apache-activemq-4.1.1\bin\activemq.bat, and it'll start the server.

By default it runs on port 61616. 

 

The admin tool is located: http://localhost:8161/admin/

 

Click the RRS feeds to see the current queue messages

 

5.x enable admin http

activemq.xml (5.67 kb)

jetty.xml (4.23 kb)

Keywords:

Filed Under: Active MQ

Eclipse Shortcut Keystroke Cheatsheet

The Eclipse platform can be used as a Java development environment. Here are some handy keyboard shortcuts when using it in that capacity. (Note that this is a small subset of the keystrokes available, however these are the ones that I call upon the most.) The official full list of default keyboard shortcuts is also helpful.

NAVIGATION
Ctl-H Search When editing Java files this will open a Java search
Ctl-Shift-T Open type Opens a dialog box for searching for class
Ctl-Shift-R Open resource Opens a dialog box for searching for a file
Ctl-Shift-G Find references Searches the workspace for references to the item under the cursor
Ctl-G Find declarations Searches the workspace for declarations of to the item under the cursor
F3 Open declaration Navigates to the declaration of the item under the cursor (Open current selected)
Ctl-T Pop-up type hierarchy Pops up a window displaying the type hierarchy
Ctl-O Pop-up members Pops up a searchable window displaying the members; pressing the key again toggles the display of inherited members
Alt-Left Back  
Alt-Right Forward  
Ctl-PgUp Switch to tab left  
Ctl-PgDown Switch to tab right  
Ctl-Up Scroll line up Moves up the position of the file being edited
Ctl-Down Scroll line down Moves down the position of the file being edited
Ctl-M Maximize active editor Toggles the maximization of the current editor
Ctl-W Close active editor window  
Ctl-E Show current editors window  

CODING
F2 Show tooltip Provides a tooltip for the item under the cursor
Ctl-1 Quick fix Allows for automatic help while coding, such as adding an import, or delaration
Ctl-Shift-O Organize imports Arranges imports based on the workspace configuration
Ctl-I Correct indentation Corrects the indentation of the current line or selected text
Ctl-Space Content assist Provides completion help while typing
Ctl-D Delete the current line  
Ctl-Shift-F Format code  

REFACTORING
Alt-Shift-R Rename Renames the item under the cursor, updating the references
Alt-Shift-L Extract local variable Extracts the expression under the cursor to a local variable and updates references to the same expression with that new variable

DEBUGGING
F5 Step into  
F6 Step over  
F7 Step return Also known as step out
F8 Resume  
Ctl-R Run to line  
F11 Debug last launched  
Ctl-Shift-B Toggle line breakpoint Toggles a breakpoint on the current line

Editor
Ctl-C Copy Copy selected text
Ctl-Y Redo Redo the last change
Ctl-Z Undo Undo the last change

Keywords:

Filed Under: Eclipse

Eclipse Shortcust

<cntrl><shift> P              Jump between braces {  }

<cntrl> /                           Comment selected lines.

Keywords:

Filed Under: Eclipse

Eclipse and Java: Introducing Persistence

Original location: http://eclipsetutorial.sourceforge.net/persistence.html

Companion document: Persistence-Tutorial-Companion-Document.pdf (248.97 kb)

Lesson 1

  • Create Java project in Eclipse using Import from archive file
  • Learn how to export a project
  • Review of MyLibrary classes
  • Introduce try / catch blocks
  • Create a Scrapbook page
  • Run try / catch blocks inside Scrapbook
  • Checking Javadoc location and Source attachment
  • persistence-lesson01.zip

Lesson 2

  • Convert from JUnit 3 to JUnit 4
  • Introduce Java Annotations
  • Plan methods for converting objects to XML text files
  • Discuss Static Methods
  • Start test method for saveStringToFile() method
  • persistence-lesson02.zip

Lesson 3

  • Complete test method for saveStringToFile() method
  • DIscuss unit tests as class documentation in agile software development
  • Start actual saveStringToFile() method
  • persistence-lesson03.zip

Lesson 4

  • Finish on saveStringToFile() method
  • Discuss BufferedWriter and FileWriter classes
  • Discuss exceptions and throws keyword
  • persistence-lesson04.zip

Lesson 5

  • Finish getStringFromFile() method
  • TODO and Tasks View
  • Run MyUtilitiesTest JUnit test
  • Reading Stack Trace
  • persistence-lesson05.zip

Lesson 6

  • Download and add XStream XML program library to our project
  • Attach source code to Java language classes to our project
  • Learn how to browse the Java source code
  • Learn how to use the Eclipse Hierarchy view
  • Use Eclipse to automatically create equals() and hashCode() methods for Person class
  • persistence-lesson06.zip

Lesson 7

  • Automatically create equals() and hashcode() methods for Book and MyLibrary classes
  • Use Elclipse Open Declaration and Open Type Hierarchy to explore Java language classes
  • Discuss the benefits of XML format
  • Write test method for convertToXML() and convertFromXML() methods
  • persistence-lesson07.zip

Lesson 8

  • Create convertToXML() and convertFromXML() methods
  • Look at XStream web tutorial
  • Test conversion methods
  • Write test method to test conversion to and from XML disk file
  • persistence-lesson08.zip

Lesson 9

  • Create saveMyLibraryToXMLFile() and getMyLibraryFromXMLFile() methods
  • Test our methods
  • Use Eclipse XML editor to examine XML file
  • XML object reference options in XStream
  • Use the Eclipse Compare With Local History feature to compare versions of XML files
  • persistence-lesson09.zip

Lesson 10

  • History View and Compare With Local for Java Source
  • Modify MyLibrary main method and run as Java application in Eclipse
  • Learn about Java class and JAR files
  • Create JAR manifest file with Class-Path
  • Set Java compiler compliance level
  • Create JAR file in Eclipse
  • Execute JAR file in Windows and Linux
  • persistence-lesson10.zip

Lesson 11

  • Overview of Java Object Serialization
  • Discuss the pros and cons of object serialization and XML
  • Create test method for saveMyLibraryToSerialFile() and getMyLibraryFromSerialFile() methods
  • Write saveMyLibraryToSerialFile() method
  • persistence-lesson11.zip

Lesson 12

  • Write getMyLibraryToSerialFile() method
  • Add Serializable interface and serialVersionUID to classes
  • Modify and run AllTests to test the entire application
  • Look at Java Compiler Errors/Warning options
  • persistence-lesson12.zip

 

Keywords:

Filed Under: Eclipse · Tutorials

Sun Developer Network - SDN

email: davidq@qbytesworld.com

pswd: my favorite QBytes passworld

screen name: QBytesWorld

Keywords:

Filed Under:

TextBox widget example - adding any formatted HTML code to the widget.

Comment List

  • None

Month List