Created
April 29, 2015 10:56
-
-
Save panayotkulchev/e2d9aa55bc5c922ccd76 to your computer and use it in GitHub Desktop.
Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import adapter.db.ConnectionProvider; | |
import adapter.db.JdbcConnectionProvider; | |
import adapter.db.PersistentFundsRepository; | |
import adapter.db.PersistentSessionRepository; | |
import adapter.db.PersistentUserRepository; | |
import adapter.http.ConnectionFilter; | |
import adapter.http.LoginFilter; | |
import adapter.http.SecurityFilter; | |
import com.google.inject.AbstractModule; | |
import com.google.inject.Guice; | |
import com.google.inject.Injector; | |
import com.google.inject.servlet.GuiceServletContextListener; | |
import com.google.inject.servlet.ServletModule; | |
import com.google.sitebricks.SitebricksModule; | |
import core.FundsRepository; | |
import core.SessionRepository; | |
import core.UserRepository; | |
import pages.Deposit; | |
import pages.Login; | |
import pages.Logout; | |
import pages.Menu; | |
import pages.Register; | |
import pages.Welcome; | |
import pages.Withdraw; | |
/** | |
* Created by Panayot Kulchev on 15-4-27. | |
* e-mail: [email protected] | |
* happy coding ... | |
*/ | |
public class AppConfig extends GuiceServletContextListener { | |
@Override | |
protected Injector getInjector() { | |
return Guice.createInjector( | |
new ServletModule() { | |
@Override | |
protected void configureServlets() { | |
filter("/*").through(ConnectionFilter.class); | |
filter("/login").through(LoginFilter.class); | |
filter("/welcome").through(SecurityFilter.class); | |
filter("/withdraw").through(SecurityFilter.class); | |
filter("/deposit").through(SecurityFilter.class); | |
filter("/menu").through(SecurityFilter.class); | |
} | |
}, | |
new SitebricksModule() { | |
@Override | |
protected void configureSitebricks() { | |
at("/register").show(Register.class); | |
at("/login").show(Login.class); | |
at("/welcome").show(Welcome.class); | |
at("/deposit").show(Deposit.class); | |
at("/withdraw").show(Withdraw.class); | |
at("/logout").show(Logout.class); | |
at("/menu").show(Menu.class); | |
embed(Menu.class).as("Hello"); | |
} | |
}, | |
new AbstractModule() { | |
@Override | |
protected void configure() { | |
bind(ConnectionProvider.class).to(JdbcConnectionProvider.class); | |
bind(SessionRepository.class).to(PersistentSessionRepository.class); | |
bind(UserRepository.class).to(PersistentUserRepository.class); | |
bind(FundsRepository.class).to(PersistentFundsRepository.class); | |
} | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
<title>Deposit funds</title> | |
<link rel="stylesheet" href="css/main.css"/> | |
</head> | |
<body style="background-color: #f0f0f0"> | |
<div id="includedContent"></div> | |
<div id="container-wide"> | |
<!--<p>${message}</p>--> | |
<div align="center"> | |
<h6 style="color: #5e5e5e">DEPOSIT FUNDS</h6> | |
<form action="/deposit" method="post"> | |
<input type="text" name="amount" placeholder="0"/> | |
<p></p> | |
<input type="submit" value="DEPOSIT"/> | |
</form> | |
</div> | |
</div> | |
<div> | |
@Hello | |
<span> | |
This text is replaced by the embed. | |
</span> | |
</div> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> | |
<script> | |
$(function () { | |
$("#includedContent").load("/menu"); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment