Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Jun 21, 2013
1 parent 21c7e6c commit 2ef7d1c
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,46 @@
*/
package org.gatein.portal.ui.register;

import javax.inject.Inject;

import juzu.Action;
import juzu.Path;
import juzu.Response;
import juzu.View;
import juzu.template.Template;

import javax.inject.Inject;

/**
* @author Julien Viet
*/
public class Controller {

@Inject
@Path("index.gtmpl")
Template index;

@Inject
Flash flash;

@View
public Response index() {
return index.with().ok();
}

@Action
public Response register(User user, String confirmPassword) {
if (!user.password.equals(confirmPassword)) {
flash.setError("Password and Confirm Password must be the same.");
return Controller_.index();
}
User isExisted = User.getUser(user.userName);
if (isExisted != null) {
flash.setError("This user is already existed. Please enter different userName.");
return Controller_.index();
}
User.saveUser(user);
flash.setSuccess("You have successfully registered a new account!");
flash.setUserName(user.userName);
return Controller_.index();
}
@Inject
@Path("index.gtmpl")
Template index;


@Inject
Flash flash;

@View
public Response index() {
return index.with().ok();
}

@Action
public Response register(User user, String confirmPassword) {
if (!user.password.equals(confirmPassword)) {
flash.setError("Password and Confirm Password must be the same.");
return Controller_.index();
}
User isExisted = User.getUser(user.userName);
if (isExisted != null) {
flash.setError("This user is already existed. Please enter different userName.");
return Controller_.index();
}
User.saveUser(user);
flash.setSuccess("You have successfully registered a new account!");
flash.setUserName(user.userName);
return Controller_.index();
}
}
46 changes: 23 additions & 23 deletions portal/ui/src/main/java/org/gatein/portal/ui/register/Flash.java
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
package org.gatein.portal.ui.register;

import juzu.FlashScoped;

import javax.inject.Named;

import juzu.FlashScoped;

@Named("flash")
@FlashScoped
public class Flash {

private String success = "";
private String success = "";

private String error = "";
private String error = "";

private String userName = "";
private String userName = "";

public String getSuccess() {
return success;
}
public String getSuccess() {
return success;
}

public void setSuccess(String success) {
this.success = success;
}
public void setSuccess(String success) {
this.success = success;
}

public String getError() {
return error;
}
public String getError() {
return error;
}

public void setError(String error) {
this.error = error;
}
public void setError(String error) {
this.error = error;
}

public String getUserName() {
return userName;
}
public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}
public void setUserName(String userName) {
this.userName = userName;
}

}
60 changes: 30 additions & 30 deletions portal/ui/src/main/java/org/gatein/portal/ui/register/User.java
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
package org.gatein.portal.ui.register;

import juzu.Mapped;

import java.util.LinkedHashMap;
import java.util.Map;

import juzu.Mapped;

@Mapped
public class User {
public String userName;
public String userName;

public String password;
public String password;

public String firstName;
public String firstName;

public String lastName;
public String lastName;

public String displayName;
public String displayName;

public String emailAddress;
public String emailAddress;

private static final Map<String, User> users = new LinkedHashMap<String, User>();
private static final Map<String, User> users = new LinkedHashMap<String, User>();

public User() {
}
public User() {
}

public User(String userName, String password, String firstName, String lastName, String displayName,
String emailAddress) {
this.userName = userName;
this.password = password;
this.firstName = firstName;
this.lastName = lastName;
this.displayName = displayName;
this.emailAddress = emailAddress;
}
public User(String userName, String password, String firstName, String lastName, String displayName,
String emailAddress) {
this.userName = userName;
this.password = password;
this.firstName = firstName;
this.lastName = lastName;
this.displayName = displayName;
this.emailAddress = emailAddress;
}

public static void saveUser(User user) {
System.out.println("save " + user.toString());
users.put(user.userName, user);
}
public static void saveUser(User user) {
System.out.println("save " + user.toString());
users.put(user.userName, user);
}

public static User getUser(String userName) {
return users.get(userName);
}
public static User getUser(String userName) {
return users.get(userName);
}

public String toString() {
return "User (userName = " + this.userName + ")";
}
public String toString() {
return "User (userName = " + this.userName + ")";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
*/
@Application
@Bindings({
@Binding(Flash.class)
@Binding(Flash.class)
})
@Portlet
@Assets(stylesheets = @Stylesheet(src = "registerportlet.css"))
package org.gatein.portal.ui.register;
@Assets(stylesheets = @Stylesheet(src = "registerportlet.css")) package org.gatein.portal.ui.register;

import juzu.Application;
import juzu.plugin.asset.Assets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
*/
package org.gatein.portal.ui.sitemap;

import javax.inject.Inject;

import juzu.Path;
import juzu.Response;
import juzu.View;
import juzu.request.UserContext;
import juzu.template.Template;

import org.gatein.portal.mop.description.DescriptionService;
import org.gatein.portal.mop.hierarchy.NodeContext;
import org.gatein.portal.mop.hierarchy.Scope;
Expand All @@ -33,32 +34,30 @@
import org.gatein.portal.mop.site.SiteKey;
import org.gatein.portal.ui.navigation.UserNode;

import javax.inject.Inject;

/**
* @author Julien Viet
*/
public class Controller {

@Inject
@Path("index.gtmpl")
Template index;
@Inject
@Path("index.gtmpl")
Template index;

@Inject
NavigationService navigationService;
@Inject
NavigationService navigationService;

@Inject
DescriptionService descriptionService;
@Inject
DescriptionService descriptionService;

@View
public Response.Content index(UserContext userContext) {
NavigationContext navigation = navigationService.loadNavigation(SiteKey.portal("classic"));
@View
public Response.Content index(UserContext userContext) {
NavigationContext navigation = navigationService.loadNavigation(SiteKey.portal("classic"));

UserNode.Model model = new UserNode.Model(descriptionService, userContext.getLocale());
UserNode.Model model = new UserNode.Model(descriptionService, userContext.getLocale());

NodeContext<UserNode, NodeState> root = navigationService.loadNode(model, navigation, Scope.ALL, null);
NodeContext<UserNode, NodeState> root = navigationService.loadNode(model, navigation, Scope.ALL, null);

return index.with().set("root", root.getNode()).ok();
}
return index.with().set("root", root.getNode()).ok();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
*/
@Application
@Bindings({
@Binding(NavigationService.class),
@Binding(DescriptionService.class)
@Binding(NavigationService.class),
@Binding(DescriptionService.class)
})
@Portlet(name = "SiteMapPortlet")
@Assets(stylesheets = @Stylesheet(src = "sitemap.css"),
scripts = {
@Script(src = "jquery-1.7.1.min.js"),
@Script(src = "sitemap.js")
})
package org.gatein.portal.ui.sitemap;
}) package org.gatein.portal.ui.sitemap;

import juzu.Application;
import juzu.plugin.asset.Assets;
Expand Down

0 comments on commit 2ef7d1c

Please sign in to comment.