Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

This page ist outdated !
We switched our code base to a REST based architecture.

 

 

 

 

 

 

Code Block
themeEclipse
languagejava
titleNewGameActionBean
firstline1
linenumberstrue
@UrlBinding("/experimental/new/game")
public class NewGameActionBean extends BaseActionBean implements ActionBean {

	private final static String JSP_NEWGAME = "/jsp/experimental/new_game.jsp";
	private Game game = null;

	@DefaultHandler
	public Resolution defaultHandler() {
		return new ForwardResolution(JSP_NEWGAME);
	}

	public Resolution update() {
		if (this.game!=null) {
			this.setDebugString(game.toWebString());
		}
		return new ForwardResolution(JSP_NEWGAME);
	}

	public Game getGame() {
		return game;
	}

	@ValidateNestedProperties({
		@Validate(field="mainTitle", required=true, on="update")
	})
	public void setGame(Game game) {
		this.game = game;
	}
}

...

Very simple way to determine the URL under which the site will be available.
line 7:
@DefaultHandler
This Method is called when the URL is visited. Returns a Resolution to the JSP-File new_game.jsp.
line 12:
public Resolution update() {
This method is called when the HTML-Form-Submit-Button (see below in new_game.jsp) is clicked (<stripes:submit name="update">).
The methods getGame and setGame srepresent the Bean property "game", which can be accessed (read and write) from the corresponding jsp file.
line 24:
@Validate(field="mainTitle", required=true, on="update")
The form field  "game.mainTitle" is validated (must not be empty) in the methode "update".

 

 

Code Block
languagehtml/xml
titlenew_game.jsp
firstline1
linenumberstrue
<%@ include file="/WEB-INF/taglibs.jspp"%>

<stripes:layout-render name="/jsp/layout/main.jsp">

<stripes:layout-component name="html_head">
 <link rel="stylesheet" href="${contextPath}/css/easy-accordion.css" />
</stripes:layout-component>

<stripes:layout-component name="contents">

<stripes:form beanclass="org.oregami.action.experimental.NewGameActionBean">
<table class="form">
    <tr><td>
 
          mainTitle: <stripes:text name="game.mainTitle" class="required"/> 
    </td>
    <td>
        <stripes:errors field="game.mainTitle"></stripes:errors>
    </td></tr>
    <tr><td>
        description: <stripes:text name="game.description"/>
    </td></tr>
    <tr><td colspan="1">
        <stripes:submit name="update"><fmt:message key="aktualisieren"/></stripes:submit>
    </td></tr>
</table>
</stripes:form>   

</stripes:layout-component>
</stripes:layout-render>

line 17:
<
stripes:errors field="game.mainTitle"></stripes:errors>

Displays the error message for the field "mainTitle" of the property "game" (if an error exists).

 

Feel free to have a look at our real Source Code at Github:

NewGameActionBean.java

new_game.jsp