Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- inject DataSource in GenericDao

  • Loading branch information...
commit b09695c140b7c654c0b3b0d8a9d1401f847ccd7d 1 parent ff5ebf8
Alex Biehl alexbiehl authored
8 src/main/java/org/fhw/asta/kasse/client/components/SessionManagerComponent.java
View
@@ -20,7 +20,13 @@ public String getUserEmail() {
}
public void setLoggedIn(String email) {
- Cookies.setCookie(COOKIE_NAME, email);
+
+ if (!Strings.isNullOrEmpty(email)) {
+ Cookies.setCookie(COOKIE_NAME, email);
+ } else {
+ Cookies.removeCookie(COOKIE_NAME);
+ }
+
}
}
9 src/main/java/org/fhw/asta/kasse/client/controller/TopbarController.java
View
@@ -36,15 +36,17 @@ public void init(EventBus eventBus) {
private void onLogin() {
//topbarWidget.setWidget(readyTopbarWidget);
- readyTopbarWidget.getQuickBoxHandlers().addChangeHandler(new QuickBoxHandler());
+ //readyTopbarWidget.getQuickBoxHandlers().addChangeHandler(new QuickBoxHandler());
}
private class QuickBoxHandler implements ChangeHandler {
@Override
public void onChange(ChangeEvent event) {
- HasText quickBox = readyTopbarWidget.getQuickBox();
- String qText = quickBox.getText();
+ //HasText quickBox = readyTopbarWidget.getQuickBox();
+
+
+ String qText ="";
if(qText.matches("[a-zA-Z][0-9]+")){
if(qText.matches("[aA][0-9]+")){
@@ -52,7 +54,6 @@ public void onChange(ChangeEvent event) {
} // else if(qText.matches.....
}
- quickBox.setText("");
}
}
3  src/main/java/org/fhw/asta/kasse/client/widget/topbar/ready/ReadyTopBarWidget.java
View
@@ -2,9 +2,8 @@
import org.fhw.asta.kasse.client.widget.topbar.TopbarWidget;
import org.fhw.asta.kasse.client.widget.topbar.modules.navbar.NavBarWidget;
-import org.fhw.asta.kasse.client.widget.topbar.modules.quickbox.QuickBoxWidget;
import org.fhw.asta.kasse.client.widget.topbar.modules.searchbox.SearchBoxWidget;
-public interface ReadyTopBarWidget extends TopbarWidget, NavBarWidget, QuickBoxWidget, SearchBoxWidget {
+public interface ReadyTopBarWidget extends TopbarWidget, NavBarWidget, SearchBoxWidget {
}
17 src/main/java/org/fhw/asta/kasse/client/widget/topbar/ready/ReadyTopBarWidgetImpl.java
View
@@ -32,15 +32,9 @@ public ReadyTopBarWidgetImpl() {
NavBarWidget navBar;
@Inject
- QuickBoxWidget quickBox;
-
- @Inject
SearchBoxWidget searchBox;
@UiField
- HTMLPanel quickBoxPanel;
-
- @UiField
HTMLPanel navBarPanel;
@UiField
@@ -50,11 +44,9 @@ public ReadyTopBarWidgetImpl() {
public void init(NavBarWidget navBar, QuickBoxWidget quickBox, SearchBoxWidget searchBox)
{
this.navBar = navBar;
- this.quickBox = quickBox;
this.searchBox = searchBox;
searchBoxPanel.add(searchBox);
- quickBoxPanel.add(quickBox);
navBarPanel.add(navBar);
}
@@ -64,18 +56,9 @@ public HasAnimation getNavBar() {
}
@Override
- public HasText getQuickBox() {
- return quickBox.getQuickBox();
- }
-
- @Override
public HasText getSearchBox() {
return searchBox.getSearchBox();
}
- @Override
- public HasChangeHandlers getQuickBoxHandlers() {
- return quickBox.getQuickBoxHandlers();
- }
}
7 src/main/java/org/fhw/asta/kasse/client/widget/topbar/ready/ReadyTopBarWidgetImpl.ui.xml
View
@@ -5,6 +5,11 @@
<div class="brand">Kasse</div>
<g:HTMLPanel styleName="navbar-search pull-left" ui:field="searchBoxPanel" />
<g:HTMLPanel ui:field="navBarPanel" />
- <g:HTMLPanel styleName="navbar-search pull-right" ui:field="quickBoxPanel" />
+
+ <div class="navbar-search pull-right">
+ <ul class="nav" >
+ <li><a href="#UserListPlace:">Logout</a></li>
+ </ul>
+ </div>
</g:HTMLPanel>
</ui:UiBinder>
5 src/main/java/org/fhw/asta/kasse/server/dao/ArticleDao.java
View
@@ -1,12 +1,16 @@
package org.fhw.asta.kasse.server.dao;
+import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Statement;
import java.util.List;
import org.fhw.asta.kasse.shared.common.EuroAmount;
import org.fhw.asta.kasse.shared.model.Article;
import org.fhw.asta.kasse.shared.model.Category;
+import org.springframework.dao.DataAccessException;
+import org.springframework.jdbc.core.ConnectionCallback;
import org.springframework.jdbc.core.RowMapper;
public class ArticleDao extends GenericDao {
@@ -31,6 +35,7 @@ public Category mapRow(final ResultSet arg0, final int arg1)
}
public List<Article> getAllArticles() {
+
return this.template
.query("SELECT article_id,"
+ "article_revision, name, description, price, tax_category_name,"
32 src/main/java/org/fhw/asta/kasse/server/dao/GenericDao.java
View
@@ -1,5 +1,7 @@
package org.fhw.asta.kasse.server.dao;
+import javax.sql.DataSource;
+
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
@@ -7,20 +9,22 @@
import com.google.common.base.Optional;
import com.google.inject.Inject;
-public abstract class GenericDao
-{
- @Inject
- protected JdbcTemplate template;
+public abstract class GenericDao {
+ @Inject
+ protected JdbcTemplate template;
+
+ @Inject
+ protected DataSource dataSource;
- protected <T> Optional<T> queryForObject(String sql, Object[] objects, RowMapper<T> rowMapper) {
+ protected <T> Optional<T> queryForObject(String sql, Object[] objects,
+ RowMapper<T> rowMapper) {
+
+ try {
+ T result = template.queryForObject(sql, objects, rowMapper);
+ return Optional.of(result);
+ } catch (EmptyResultDataAccessException e) {
+ return Optional.absent();
+ }
+ }
- try {
- T result = template.queryForObject(sql, objects, rowMapper);
- return Optional.of(result);
- } catch (EmptyResultDataAccessException e) {
- return Optional.absent();
- }
- }
-
-
}
Please sign in to comment.
Something went wrong with that request. Please try again.