You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2013/01/30 10:54:16 UTC
svn commit: r1440322 [2/3] - in
/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi: ./
resource/ src/ src/main/ src/main/appended-resources/
src/main/appended-resources/META-INF/ src/main/java/ src/main/java/org/
src/main/java/org/apac...
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/Controller.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/Controller.java?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/Controller.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/Controller.java Wed Jan 30 09:54:14 2013
@@ -0,0 +1,428 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.example.addressbook.web;
+
+import org.apache.commons.fileupload.FileItem;
+import org.apache.myfaces.tobago.component.UIColumn;
+import org.apache.myfaces.tobago.component.UISheet;
+import org.apache.myfaces.tobago.config.TobagoConfig;
+import org.apache.myfaces.tobago.context.ClientProperties;
+import org.apache.myfaces.tobago.context.Theme;
+import org.apache.myfaces.tobago.event.SortActionEvent;
+import org.apache.myfaces.tobago.example.addressbook.Address;
+import org.apache.myfaces.tobago.example.addressbook.AddressDao;
+import org.apache.myfaces.tobago.example.addressbook.JpaAddressDao;
+import org.apache.myfaces.tobago.example.addressbook.Picture;
+import org.apache.myfaces.tobago.model.SheetState;
+import org.apache.myfaces.tobago.util.VariableResolverUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.SessionScoped;
+import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+import javax.faces.model.SelectItem;
+import javax.faces.validator.ValidatorException;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+@Named("controller")
+@SessionScoped
+public class Controller implements Serializable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(Controller.class);
+
+ private static final String OUTCOME_LIST = "list";
+ private static final String OUTCOME_EDITOR = "editor";
+
+ private List<Address> currentAddressList;
+ private Address currentAddress;
+ private SheetState selectedAddresses;
+
+ private String searchCriterion;
+
+ private Locale language;
+
+ private List<SelectItem> languages = new ArrayList<SelectItem>();
+
+ @Inject
+ private Countries countries;
+
+ private Theme theme;
+
+ private List<SelectItem> themeItems = new ArrayList<SelectItem>();
+
+ private boolean simple;
+
+ private boolean renderPopup;
+ private boolean renderFirstName = true;
+ private boolean renderLastName = true;
+ private boolean renderDayOfBirth = true;
+
+ @Inject
+ private AddressDao addressDao;
+
+ private FileItem uploadedFile;
+ private boolean renderFileUploadPopup;
+
+ public Controller() {
+ LOG.info("controller constructor ****************************************************************************************************");
+ }
+
+ @PostConstruct
+ public void init() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Application application = facesContext.getApplication();
+ language = application.getDefaultLocale();
+ countries.init(language);
+ facesContext.getExternalContext().getSession(true);
+ initLanguages();
+
+ TobagoConfig tobagoConfig = TobagoConfig.getInstance(facesContext);
+ List<Theme> themes = new ArrayList<Theme>(tobagoConfig.getSupportedThemes());
+ themes.add(0, tobagoConfig.getDefaultTheme());
+ themeItems = new ArrayList<SelectItem>();
+ for (Theme theme : themes) {
+ themeItems.add(new SelectItem(theme, theme.getDisplayName()));
+ }
+
+ ClientProperties client = VariableResolverUtils.resolveClientProperties(facesContext);
+ theme = client.getTheme();
+ currentAddressList = addressDao.findAddresses(searchCriterion);
+ }
+
+ public void setAddressDao(AddressDao addressDao) {
+ this.addressDao = addressDao;
+ }
+
+ public void sheetSorter(ActionEvent event) {
+ if (event instanceof SortActionEvent) {
+ SortActionEvent sortEvent = (SortActionEvent) event;
+ UIColumn column = (UIColumn) sortEvent.getColumn();
+
+ SheetState sheetState = ((UISheet) sortEvent.getSheet()).getSheetState(FacesContext.getCurrentInstance());
+ currentAddressList = addressDao.findAddresses(searchCriterion, column.getId(), sheetState.isAscending());
+ }
+ }
+
+ public String search() {
+ currentAddressList = addressDao.findAddresses(searchCriterion);
+ return OUTCOME_LIST;
+ }
+
+ public String createAddress() {
+ LOG.debug("action: createAddress");
+ currentAddress = new Address();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Locale locale = facesContext.getViewRoot().getLocale();
+ // XXX use better datatype for countries than Locale
+ if (Locale.GERMAN.equals(locale)) {
+ locale = Locale.GERMANY;
+ }
+ currentAddress.setCountry(locale);
+ return OUTCOME_EDITOR;
+ }
+
+ public String addDummyAddresses() throws IOException {
+ for (int i=0; i<100; ++i) {
+ currentAddress = RandomAddressGenerator.generateAddress();
+ store();
+ }
+ return OUTCOME_LIST;
+ }
+
+ public String editAddress() {
+ LOG.debug("action: editAddress");
+ List<Integer> selection = selectedAddresses.getSelectedRows();
+ if (selection.size() != 1) {
+ FacesMessage error = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Please select exactly one address!", null);
+ FacesContext.getCurrentInstance().addMessage(null, error);
+ return null;
+ }
+ currentAddress = currentAddressList.get(selection.get(0));
+ return OUTCOME_EDITOR;
+ }
+
+ public String deleteAddresses() {
+ List<Integer> selection = selectedAddresses.getSelectedRows();
+ if (selection.size() < 1) {
+ FacesMessage error = new FacesMessage("Please select at least one address.");
+ FacesContext.getCurrentInstance().addMessage(null, error);
+ return null;
+ }
+ Collections.sort(selection); // why?
+ for (int i = selection.size() - 1; i >= 0; i--) {
+ Address address = currentAddressList.get(selection.get(i));
+ addressDao.removeAddress(address);
+ }
+ selectedAddresses.resetSelected();
+ currentAddressList = addressDao.findAddresses(searchCriterion);
+ return OUTCOME_LIST;
+ }
+
+ public String store() {
+ LOG.debug("action: storeAddress");
+ currentAddress = addressDao.updateAddress(currentAddress);
+ selectedAddresses.resetSelected();
+ currentAddressList = addressDao.findAddresses(searchCriterion);
+ return OUTCOME_LIST;
+ }
+
+ public String cancel() {
+ currentAddressList = addressDao.findAddresses(searchCriterion);
+ return OUTCOME_LIST;
+ }
+
+ public String languageChangedList() {
+ initLanguages();
+ return OUTCOME_LIST;
+ }
+
+ public String themeChanged() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ClientProperties client = VariableResolverUtils.resolveClientProperties(facesContext);
+ client.setTheme(theme);
+ return null;
+ }
+
+ public String getCurrentAddressPictureUrl() {
+ return (currentAddress != null && currentAddress.getPicture() != null)
+ ? FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath() + "/faces/picture?id=XXXX"
+ :"image/empty-portrait.png";
+
+ }
+
+ public void validatePhoneNumber(
+ FacesContext context, UIComponent component, Object value) {
+ String phoneNumber = (String) value;
+ if (phoneNumber == null || phoneNumber.length() == 0) {
+ return;
+ }
+ if (!phoneNumber.matches("\\+?[0-9 ]*(\\([0-9 ]*\\))?[0-9 ]*")) {
+ throw new ValidatorException(MessageUtils.createErrorMessage(
+ "validatorPhone", context));
+ }
+ }
+
+ public List getCurrentAddressList() {
+ return currentAddressList;
+ }
+
+ public Address getCurrentAddress() {
+ return currentAddress;
+ }
+
+ public SheetState getSelectedAddresses() {
+ return selectedAddresses;
+ }
+
+ public void setSelectedAddresses(SheetState selectedAddresses) {
+ this.selectedAddresses = selectedAddresses;
+ }
+
+ public boolean isRenderFileUploadPopup() {
+ return renderFileUploadPopup;
+ }
+
+ public void setRenderFileUploadPopup(boolean renderFileUploadPopup) {
+ LOG.debug(">>> " + renderFileUploadPopup);
+ this.renderFileUploadPopup = renderFileUploadPopup;
+ }
+
+ public String cancelFileUploadPopup() {
+ setRenderFileUploadPopup(false);
+ return null;
+ }
+
+ public void setRenderPopup(boolean renderPopup) {
+ this.renderPopup = renderPopup;
+ }
+
+ public boolean isRenderPopup() {
+ return renderPopup;
+ }
+
+ public String selectColumns() {
+ setRenderPopup(true);
+ return OUTCOME_LIST;
+ }
+
+ public String okFileUpload() {
+ setRenderFileUploadPopup(false);
+ Picture picture = new Picture(uploadedFile.getContentType(), uploadedFile.get());
+ currentAddress.setPicture(picture);
+ return null;
+ }
+
+ public String cancelFileUpload() {
+ setRenderFileUploadPopup(false);
+ return null;
+ }
+
+ public String cancelPopup() {
+ setRenderPopup(false);
+ return OUTCOME_LIST;
+ }
+
+ public String logout() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(false);
+ if (session != null) {
+ session.invalidate();
+ }
+ return "logout";
+ }
+
+ public String getVersion() {
+ return getClass().getPackage().getImplementationVersion();
+ }
+
+ public Locale getLanguage() {
+ return language;
+ }
+
+ public String getDisplayLanguage() {
+ return language.getDisplayName(language);
+ }
+
+ public void setLanguage(Locale language) {
+ this.language = language;
+ }
+
+ public List<SelectItem> getLanguages() {
+ return languages;
+ }
+
+ public void setLanguages(List<SelectItem> languages) {
+ this.languages = languages;
+ }
+
+ public Countries getCountries() {
+ return countries;
+ }
+
+ public List<SelectItem> getThemeItems() {
+ return themeItems;
+ }
+
+ public Theme getTheme() {
+ return theme;
+ }
+
+ public void setTheme(Theme theme) {
+ this.theme = theme;
+ }
+
+ public boolean isSimple() {
+ return simple;
+ }
+
+ public void setSimple(boolean simple) {
+ this.simple = simple;
+ }
+
+ public boolean isRenderFirstName() {
+ return renderFirstName;
+ }
+
+ public void setRenderFirstName(boolean renderFirstName) {
+ this.renderFirstName = renderFirstName;
+ }
+
+ public boolean isRenderLastName() {
+ return renderLastName;
+ }
+
+ public void setRenderLastName(boolean renderLastName) {
+ this.renderLastName = renderLastName;
+ }
+
+ public boolean isRenderDayOfBirth() {
+ return renderDayOfBirth;
+ }
+
+ public void setRenderDayOfBirth(boolean renderDayOfBirth) {
+ this.renderDayOfBirth = renderDayOfBirth;
+ }
+
+ public FileItem getUploadedFile() {
+ return uploadedFile;
+ }
+
+ public void setUploadedFile(FileItem uploadedFile) {
+ this.uploadedFile = uploadedFile;
+ }
+
+ public String getSearchCriterion() {
+ return searchCriterion;
+ }
+
+ public void setSearchCriterion(String searchCriterion) {
+ this.searchCriterion = searchCriterion;
+ }
+
+ public String popupFileUpload() {
+ setRenderFileUploadPopup(true);
+ return null;
+ }
+
+ public String languageChanged() {
+ countries.init(language);
+ initLanguages();
+/*
+ // reinit date converter
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ UIViewRoot viewRoot = facesContext.getViewRoot();
+ EditableValueHolder component = (EditableValueHolder)
+ viewRoot.findComponent(":page:dayOfBirth");
+ if (component != null) {
+ DateTimeConverter converter = (DateTimeConverter) component.getConverter();
+ converter.setPattern(MessageUtils.getLocalizedString(facesContext, "editor_date_pattern"));
+ }
+*/
+ return null;
+ }
+
+ private void initLanguages() {
+ languages.clear();
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Application application = facesContext.getApplication();
+ Iterator supportedLocales = application.getSupportedLocales();
+ while (supportedLocales.hasNext()) {
+ Locale locale = (Locale) supportedLocales.next();
+ SelectItem item = new SelectItem(locale, locale.getDisplayName(language));
+ languages.add(item);
+ }
+ Collections.sort(languages, new SelectItemComparator());
+ }
+
+}
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/Countries.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/Countries.java?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/Countries.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/Countries.java Wed Jan 30 09:54:14 2013
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.example.addressbook.web;
+
+import javax.enterprise.context.SessionScoped;
+import javax.faces.model.SelectItem;
+import javax.inject.Named;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Locale;
+
+@Named
+@SessionScoped
+public class Countries extends ArrayList<SelectItem> {
+
+ public void init(Locale language) {
+ clear();
+ Locale[] availableLocales = Locale.getAvailableLocales();
+ for (Locale locale : availableLocales) {
+ String displayCountry = locale.getDisplayCountry(language);
+ if (displayCountry != null && displayCountry.length() > 0) {
+ add(new SelectItem(locale, displayCountry));
+ }
+ }
+ Collections.sort(this, new SelectItemComparator());
+ }
+}
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/EmailAddressConverter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/EmailAddressConverter.java?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/EmailAddressConverter.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/EmailAddressConverter.java Wed Jan 30 09:54:14 2013
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.example.addressbook.web;
+
+/*
+ * Created 03.12.2004 00:08:01.
+ * $Id: EmailAddressConverter.java 1368242 2012-08-01 20:47:33Z lofwyr $
+ */
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.myfaces.tobago.example.addressbook.EmailAddress;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+
+public class EmailAddressConverter implements Converter {
+
+ private static final Logger LOG = LoggerFactory.getLogger(EmailAddressConverter.class);
+
+ public Object getAsObject(
+ FacesContext facesContext, UIComponent component, String reference) {
+ if (reference == null || reference.length() == 0) {
+ return null;
+ }
+ String[] parts = reference.split("@");
+ if (parts == null || parts.length != 2) {
+ throw new ConverterException(MessageUtils.createErrorMessage(
+ "converterEmailParts", facesContext));
+ }
+ return new EmailAddress(reference);
+ }
+
+ public String getAsString(
+ FacesContext facesContext, UIComponent component, Object object) {
+ return object.toString();
+ }
+
+}
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/EmailAddressValidator.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/EmailAddressValidator.java?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/EmailAddressValidator.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/EmailAddressValidator.java Wed Jan 30 09:54:14 2013
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.example.addressbook.web;
+
+import org.apache.myfaces.tobago.example.addressbook.EmailAddress;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class EmailAddressValidator implements Validator {
+
+ private static final String EMAIL_ATOM
+ = "[^()<>@,;:\\\\.\\[\\]\\\"]";
+ private static final String LOCAL_PART_SPEC
+ = EMAIL_ATOM + "+(\\." + EMAIL_ATOM + "+)*";
+ private static final String DOMAIN_SPEC
+ = EMAIL_ATOM + "+(\\." + EMAIL_ATOM + "+)+";
+
+ private static final Pattern LOCAL_PART_PATTERN
+ = Pattern.compile(LOCAL_PART_SPEC);
+ private static final Pattern DOMAIN_PATTERN
+ = Pattern.compile(DOMAIN_SPEC);
+
+ public void validate(
+ FacesContext facesContext, UIComponent uiComponent, Object value)
+ throws ValidatorException {
+ EmailAddress emailAddress = (EmailAddress) value;
+
+ Matcher matcher = LOCAL_PART_PATTERN.matcher(emailAddress.getLocalPart());
+ if (!matcher.matches()) {
+ throw new ValidatorException(MessageUtils.createErrorMessage(
+ "validatorEmailLocalPart", facesContext));
+ }
+
+ matcher = DOMAIN_PATTERN.matcher(emailAddress.getDomain());
+ if (!matcher.matches()) {
+ throw new ValidatorException(MessageUtils.createErrorMessage(
+ "validatorEmailDomain", facesContext));
+ }
+ }
+}
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/Layout.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/Layout.java?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/Layout.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/Layout.java Wed Jan 30 09:54:14 2013
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.example.addressbook.web;
+
+import org.apache.myfaces.tobago.model.PageStateImpl;
+
+/**
+ * @deprecated since 1.5.0, please configure constraints for the page size with a tc:gridLayoutConstraints tag
+ * inside the tc:page tag.
+ */
+@Deprecated
+public class Layout extends PageStateImpl {
+
+ private int width;
+ private int height;
+ private int minimumWidth;
+ private int minimumHeight;
+ private int maximumWidth;
+ private int maximumHeight;
+
+ public int getWidth() {
+ int clientWidth = getClientWidth();
+ if (clientWidth != 0) {
+ if (clientWidth < minimumWidth) {
+ return minimumWidth;
+ } else if (clientWidth > maximumWidth) {
+ return maximumWidth;
+ }
+ return clientWidth;
+ }
+ return width;
+ }
+
+ public void setWidth(int width) {
+ this.width = width;
+ }
+
+ public int getHeight() {
+ int clientHeight = getClientHeight();
+ if (clientHeight != 0) {
+ if (clientHeight < minimumHeight) {
+ return minimumHeight;
+ } else if (clientHeight > maximumHeight) {
+ return maximumHeight;
+ }
+ return clientHeight;
+ }
+ return height;
+ }
+
+ public void setHeight(int height) {
+ this.height = height;
+ }
+
+ public int getMinimumWidth() {
+ return minimumWidth;
+ }
+
+ public void setMinimumWidth(int minimumWidth) {
+ this.minimumWidth = minimumWidth;
+ }
+
+ public int getMinimumHeight() {
+ return minimumHeight;
+ }
+
+ public void setMinimumHeight(int minimumHeight) {
+ this.minimumHeight = minimumHeight;
+ }
+
+ public int getMaximumWidth() {
+ return maximumWidth;
+ }
+
+ public void setMaximumWidth(int maximumWidth) {
+ this.maximumWidth = maximumWidth;
+ }
+
+ public int getMaximumHeight() {
+ return maximumHeight;
+ }
+
+ public void setMaximumHeight(int maximumHeight) {
+ this.maximumHeight = maximumHeight;
+ }
+}
+
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/LocaleConverter.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/LocaleConverter.java?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/LocaleConverter.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/LocaleConverter.java Wed Jan 30 09:54:14 2013
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.example.addressbook.web;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+import java.util.Locale;
+
+public class LocaleConverter implements Converter {
+
+ public Object getAsObject(
+ FacesContext facesContext, UIComponent component, String value) {
+ Locale locale = createLocale(value);
+ if (locale == null) {
+ throw new ConverterException(MessageUtils.getLocalizedString(
+ facesContext, "converterLocaleParserError", value));
+ }
+ return locale;
+ }
+
+ public String getAsString(
+ FacesContext facesContext, UIComponent component, Object value) {
+ return value == null ? null : value.toString();
+ }
+
+ public static Locale createLocale(String value) {
+ String[] strings = value.split("_");
+ switch (strings.length) {
+ case 1:
+ return new Locale(strings[0]);
+ case 2:
+ return new Locale(strings[0], strings[1]);
+ case 3:
+ return new Locale(strings[0], strings[1], strings[2]);
+ default:
+ return null;
+ }
+ }
+
+}
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/LoggingController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/LoggingController.java?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/LoggingController.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/LoggingController.java Wed Jan 30 09:54:14 2013
@@ -0,0 +1,221 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.example.addressbook.web;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.log4j.Appender;
+import org.apache.log4j.Level;
+import org.apache.log4j.LogManager;
+import org.apache.myfaces.tobago.component.UIInput;
+import org.apache.myfaces.tobago.example.addressbook.Log4jUtils;
+import org.apache.myfaces.tobago.model.SelectItem;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.enterprise.context.SessionScoped;
+import javax.faces.component.UIParameter;
+import javax.faces.context.FacesContext;
+import javax.inject.Named;
+import javax.servlet.ServletResponse;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Set;
+
+@Named("logging")
+@SessionScoped
+public class LoggingController implements Serializable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(LoggingController.class);
+
+ private List<AppenderModel> appenders = new ArrayList<AppenderModel>();
+ private List<CategoryModel> categories = new ArrayList<CategoryModel>();
+ private List<SelectItem> levels = new ArrayList<SelectItem>();
+ private String category;
+ private UIInput categoryControl;
+ private String level;
+ private UIParameter currentCategory;
+ private UIParameter currentAppender;
+
+ private int catergoriesFirst;
+ private int catergoriesRows;
+
+ public LoggingController() {
+ LOG.debug("initializing...");
+ catergoriesRows = 8;
+ initAppenders();
+ initCategories();
+
+ levels.add(new SelectItem(Level.FATAL.toString()));
+ levels.add(new SelectItem(Level.ERROR.toString()));
+ levels.add(new SelectItem(Level.WARN.toString()));
+ levels.add(new SelectItem(Level.INFO.toString()));
+ levels.add(new SelectItem(Level.DEBUG.toString()));
+ levels.add(new SelectItem(Level.TRACE.toString()));
+ }
+
+ private void initCategories() {
+ categories.clear();
+ Enumeration enumeration = LogManager.getCurrentLoggers();
+ while (enumeration.hasMoreElements()) {
+ org.apache.log4j.Logger logger = (org.apache.log4j.Logger) enumeration.nextElement();
+ categories.add(new CategoryModel(logger));
+ }
+ categories.add(new CategoryModel(LogManager.getRootLogger()));
+
+ Collections.sort(categories, new Comparator<CategoryModel>() {
+ public int compare(CategoryModel c1, CategoryModel c2) {
+ org.apache.log4j.Logger l1 = c1.getLogger();
+ org.apache.log4j.Logger l2 = c2.getLogger();
+ return l1.getName().compareTo(l2.getName());
+ }
+ });
+ }
+
+ private void initAppenders() {
+ appenders.clear();
+ Set<Appender> allAppenders = Log4jUtils.getAllAppenders();
+ for (Appender appender : allAppenders) {
+ appenders.add(new AppenderModel(appender));
+ }
+ }
+
+ public String downloadLogFile() throws IOException {
+ AppenderModel appender = (AppenderModel) currentAppender.getValue();
+ String fileName = appender.getFile();
+ FileInputStream stream = new FileInputStream(fileName);
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ServletResponse response = (ServletResponse) facesContext.getExternalContext().getResponse();
+ response.setContentType("text/plain");
+ IOUtils.copy(stream, response.getOutputStream());
+ facesContext.responseComplete();
+ return null;
+ }
+
+ public String updateCategories() {
+ boolean update = false;
+ for (CategoryModel category : categories) {
+ if (category.isLevelUpdated()) {
+ org.apache.log4j.Logger logger = getLogger(category.getName());
+ logger.setLevel(Level.toLevel(category.getLevel()));
+ update = true;
+ }
+ }
+ if (update) {
+ initCategories();
+ }
+ return null;
+ }
+
+ public String addCategory() {
+ LOG.debug("debug");
+ LOG.trace("trace");
+ org.apache.log4j.Logger logger = getLogger(category);
+ logger.setLevel(Level.toLevel(level));
+ initCategories();
+ return null;
+ }
+
+ public String selectCategory() {
+ category = ((CategoryModel) currentCategory.getValue()).getName();
+ categoryControl.setSubmittedValue(category);
+ return null;
+ }
+
+ private org.apache.log4j.Logger getLogger(String category) {
+ return ("root".equals(category))
+ ? LogManager.getRootLogger()
+ : LogManager.getLogger(category);
+ }
+
+ public List<AppenderModel> getAppenders() {
+ return appenders;
+ }
+
+ public List<CategoryModel> getCategories() {
+ return categories;
+ }
+
+ public List<SelectItem> getLevels() {
+ return levels;
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ public UIInput getCategoryControl() {
+ return categoryControl;
+ }
+
+ public void setCategoryControl(UIInput categoryControl) {
+ this.categoryControl = categoryControl;
+ }
+
+ public String getLevel() {
+ return level;
+ }
+
+ public void setLevel(String level) {
+ this.level = level;
+ }
+
+ public UIParameter getCurrentCategory() {
+ return currentCategory;
+ }
+
+ public void setCurrentCategory(UIParameter currentCategory) {
+ this.currentCategory = currentCategory;
+ }
+
+ public int getCatergoriesFirst() {
+ return catergoriesFirst;
+ }
+
+ public void setCatergoriesFirst(int catergoriesFirst) {
+ this.catergoriesFirst = catergoriesFirst;
+ }
+
+ public int getCatergoriesRows() {
+ return catergoriesRows;
+ }
+
+ public void setCatergoriesRows(int catergoriesRows) {
+ this.catergoriesRows = catergoriesRows;
+ }
+
+ public UIParameter getCurrentAppender() {
+ return currentAppender;
+ }
+
+ public void setCurrentAppender(UIParameter currentAppender) {
+ this.currentAppender = currentAppender;
+ }
+
+}
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/MessageUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/MessageUtils.java?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/MessageUtils.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/MessageUtils.java Wed Jan 30 09:54:14 2013
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.example.addressbook.web;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+
+public class MessageUtils {
+
+ private MessageUtils() {
+ }
+
+ public static String getLocalizedString(FacesContext facesContext, String key) {
+ ResourceBundle bundle = ResourceBundle.getBundle(
+ facesContext.getApplication().getMessageBundle(),
+ facesContext.getViewRoot().getLocale());
+ return bundle.getString(key);
+ }
+
+ public static String getLocalizedString(FacesContext facesContext,
+ String key, String value) {
+ return MessageFormat.format(
+ getLocalizedString(facesContext, key), value);
+ }
+
+ public static String getLocalizedString(FacesContext facesContext,
+ String key, int value) {
+ return MessageFormat.format(
+ getLocalizedString(facesContext, key), value);
+ }
+
+ public static FacesMessage createErrorMessage(
+ String key, FacesContext facesContext) {
+ FacesMessage message = new FacesMessage();
+ // TODO _detail
+ message.setDetail(getLocalizedString(facesContext, key));
+ message.setSummary(getLocalizedString(facesContext, key));
+ message.setSeverity(FacesMessage.SEVERITY_ERROR);
+ return message;
+ }
+
+}
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/PictureServlet.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/PictureServlet.java?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/PictureServlet.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/PictureServlet.java Wed Jan 30 09:54:14 2013
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.example.addressbook.web;
+
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.myfaces.tobago.example.addressbook.Address;
+import org.apache.myfaces.tobago.example.addressbook.Picture;
+import org.apache.myfaces.tobago.servlet.NonFacesRequestServlet;
+import org.apache.myfaces.tobago.util.VariableResolverUtils;
+
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+
+
+public class PictureServlet extends NonFacesRequestServlet {
+ private static final Logger LOG = LoggerFactory.getLogger(PictureServlet.class);
+
+ public String invokeApplication(FacesContext facesContext) {
+ Controller controller = (Controller) VariableResolverUtils.resolveVariable(facesContext, "controller");
+ Address address = controller.getCurrentAddress();
+ if (address.hasPicture()) {
+ Picture picture = address.getPicture();
+ byte[] content = picture.getContent();
+ HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
+ if (content != null && content.length > 0) {
+ response.setContentType(picture.getContentType());
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(content);
+ try {
+ IOUtils.copy(inputStream, response.getOutputStream());
+ } catch (IOException e) {
+ LOG.error("", e);
+ } finally{
+ IOUtils.closeQuietly(inputStream);
+ }
+ }
+ facesContext.responseComplete();
+ }
+ return null;
+ }
+}
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/RandomAddressGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/RandomAddressGenerator.java?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/RandomAddressGenerator.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/RandomAddressGenerator.java Wed Jan 30 09:54:14 2013
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.example.addressbook.web;
+
+import org.apache.commons.lang.math.RandomUtils;
+import org.apache.myfaces.tobago.example.addressbook.Address;
+
+import java.util.Calendar;
+import java.util.Locale;
+
+/**
+ * Tries to generate random, uncontroversial addresses.
+ *
+ * @see <a href="http://en.wikipedia.org/wiki/John_Doe">Wikipedia: John Doe</a>
+ * @see <a href="http://en.wikipedia.org/wiki/Alice_and_Bob">Wikipedia: Alice and Bob</a>
+ * @see <a href="http://en.wikipedia.org/wiki/Placeholder_name">Wikipedia: Placeholder name</a>
+ */
+public class RandomAddressGenerator {
+
+ private static final String[] MALE_FIRST_NAMES = {
+ "Alan", "Arvid", "Bernd", "Detlef", "Frank", "Hans",
+ "John", "Max", "Michael", "Otto", "Tom", "Udo"};
+ private static final String[] FEMALE_FIRST_NAMES = {
+ "Anna", "Erika", "Jane", "Kate", "Kerstin", "Maria",
+ "Polly", "Sabine", "Shirley", "Tanya", "Tracy", "Yvonne"};
+
+ private static final String[] GERMAN_LAST_NAMES = {
+ "Müller", "Meier", "Mustermann", "Schmidt", "Schulze"};
+ private static final String[] ENGLISH_LAST_NAMES = {
+ "Doe", "Jones", "Miller", "Public", "Raymond", "Smithee"
+ };
+
+ public static Address generateAddress() {
+ return generateAddress(RandomUtils.nextBoolean(), RandomUtils.nextBoolean());
+ }
+
+ public static Address generateAddress(boolean female, boolean german) {
+ Address address = new Address();
+ address.setFirstName(female ? randomString(FEMALE_FIRST_NAMES) : randomString(MALE_FIRST_NAMES));
+ if (german) {
+ address.setLastName(randomString(GERMAN_LAST_NAMES));
+ address.setCountry(Locale.GERMANY);
+ } else {
+ address.setLastName(randomString(ENGLISH_LAST_NAMES));
+ address.setCountry(RandomUtils.nextBoolean() ? Locale.US : Locale.UK);
+ }
+ Calendar calendar = Calendar.getInstance();
+ calendar.set(1920, 0, 1);
+ calendar.add(Calendar.DAY_OF_YEAR, RandomUtils.nextInt(70 * 365));
+ address.setDayOfBirth(calendar.getTime());
+ return address;
+ }
+
+ static String randomString(String[] array) {
+ return array[RandomUtils.nextInt(array.length)];
+ }
+
+}
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/SelectItemComparator.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/SelectItemComparator.java?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/SelectItemComparator.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/SelectItemComparator.java Wed Jan 30 09:54:14 2013
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.example.addressbook.web;
+
+import javax.faces.model.SelectItem;
+import java.io.Serializable;
+import java.util.Comparator;
+
+public class SelectItemComparator implements Comparator<SelectItem>, Serializable {
+ private static final long serialVersionUID = -1581955960510873296L;
+
+ public int compare(SelectItem s1, SelectItem s2) {
+ return s1.getLabel().compareTo(s2.getLabel());
+ }
+
+}
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/StartupPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/StartupPhaseListener.java?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/StartupPhaseListener.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/StartupPhaseListener.java Wed Jan 30 09:54:14 2013
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.tobago.example.addressbook.web;
+
+import org.apache.commons.lang.BooleanUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.faces.FacesException;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+import java.io.IOException;
+
+public class StartupPhaseListener implements PhaseListener {
+
+ private static final Logger LOG = LoggerFactory.getLogger(StartupPhaseListener.class);
+ public static final String LOGGED_IN = StartupPhaseListener.class.getName() + ".LOGGED_IN";
+ public static final String PRINCIPAL = StartupPhaseListener.class.getName() + ".PRINCIPAL";
+
+ public PhaseId getPhaseId() {
+ return PhaseId.RESTORE_VIEW;
+ }
+
+ public void beforePhase(PhaseEvent event) {
+
+ FacesContext facesContext = event.getFacesContext();
+ ExternalContext externalContext = facesContext.getExternalContext();
+ String pathInfo = externalContext.getRequestPathInfo();
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("externalContext.getRequestPathInfo() = '" + pathInfo + "'");
+ }
+
+ if (pathInfo.equals("/error.xhtml") || // todo: not nice, find a declarative way.
+ pathInfo.startsWith("/auth/")) {
+ Object session = externalContext.getSession(false);
+ if (session != null) {
+ externalContext.getSessionMap().put(LOGGED_IN, Boolean.FALSE);
+ }
+ return; // nothing to do.
+ }
+
+ Boolean loggedIn = (Boolean) // todo: not nice to get this object directly from the session
+ externalContext.getSessionMap().get(LOGGED_IN);
+
+ if (!BooleanUtils.toBoolean(loggedIn)) {
+ try {
+ externalContext.getSessionMap().put(LOGGED_IN, Boolean.TRUE);
+ String forward = externalContext.getRequestContextPath() + "/faces/addressbook/start.xhtml";
+ externalContext.redirect(externalContext.encodeResourceURL(forward));
+ } catch (Exception e) {
+ LOG.error("", e);
+ String forward = externalContext.getRequestContextPath() + "/error.xhtml";
+ try {
+ externalContext.redirect(externalContext.encodeResourceURL(forward));
+ } catch (IOException e2) {
+ LOG.error("", e2);
+ throw new FacesException("Can't redirect to errorpage '" + forward + "'");
+ }
+ }
+ }
+ }
+
+ public void afterPhase(PhaseEvent event) {
+ }
+}
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/resources/META-INF/persistence.xml?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/resources/META-INF/persistence.xml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/resources/META-INF/persistence.xml Wed Jan 30 09:54:14 2013
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
+
+ <persistence-unit name="addressBook" transaction-type="RESOURCE_LOCAL">
+
+ <jta-data-source>addressBookDataSource</jta-data-source>
+<!--
+ <non-jta-data-source>addressBookDatabaseNotManaged</non-jta-data-source>
+-->
+
+ <class>org.apache.myfaces.tobago.example.addressbook.Address</class>
+ <class>org.apache.myfaces.tobago.example.addressbook.Picture</class>
+
+ <properties>
+ <property name="openjpa.RuntimeClassOptimization" value="false"/>
+ <property name="openjpa.Log" value="DefaultLevel=TRACE"/>
+ </properties>
+
+ </persistence-unit>
+</persistence>
+
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/resources/log4j.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/resources/log4j.xml?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/resources/log4j.xml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/resources/log4j.xml Wed Jan 30 09:54:14 2013
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration>
+
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Encoding" value="UTF-8"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern"
+ value="%d{HH:mm:ss} %-5p %-50.50c:%-20.20M:%-4.4L %m%n"/>
+ <!-- See http://logging.apache.org/log4j/docs/api/org/apache/log4j/PatternLayout.html -->
+ </layout>
+ </appender>
+
+ <category name="org.apache.myfaces.tobago.example.addressbook">
+ <priority value="debug" />
+ </category>
+
+ <root>
+ <priority value="info" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/META-INF/context.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/META-INF/context.xml?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/META-INF/context.xml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/META-INF/context.xml Wed Jan 30 09:54:14 2013
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<!--
+ This file is for Apache Tomcat.
+ The property "antiResourceLocking" is needed for proper redeploy under Windows.
+-->
+
+<Context antiResourceLocking="true" >
+</Context>
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/applicationContext.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/applicationContext.xml?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/applicationContext.xml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/applicationContext.xml Wed Jan 30 09:54:14 2013
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-2.5.xsd
+ http://www.springframework.org/schema/tx
+ http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
+
+ <context:annotation-config/>
+
+ <context:component-scan base-package="org.apache.myfaces.tobago.example.addressbook" />
+
+ <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
+
+ <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
+
+ <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
+ <property name="dataSource" ref="dataSource"/>
+ <property name="jpaVendorAdapter">
+ <bean class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter">
+ <property name="showSql" value="true"/>
+ <property name="generateDdl" value="true"/>
+ </bean>
+ </property>
+ <property name="persistenceUnitName" value="addressBook"/>
+ <property name="loadTimeWeaver">
+ <bean class="org.apache.myfaces.tobago.example.addressbook.OpenJpaLoadTimeWeaver"/>
+ </property>
+ </bean>
+
+ <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+ <property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver"/>
+ <property name="url" value="jdbc:derby:target/addressDB;create=true"/>
+ </bean>
+
+ <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
+ <property name="entityManagerFactory" ref="entityManagerFactory"/>
+ <property name="dataSource" ref="dataSource"/>
+ </bean>
+
+ <tx:annotation-driven />
+
+</beans>
\ No newline at end of file
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/beans.xml?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/beans.xml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/beans.xml Wed Jan 30 09:54:14 2013
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<!-- marker file for CDI -->
+
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+
+ <interceptors>
+ </interceptors>
+
+ <decorators>
+ </decorators>
+
+ <alternatives>
+ <class>org.apache.myfaces.tobago.example.addressbook.InMemoryAddressDao</class>
+ </alternatives>
+
+</beans>
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/faces-config.xml?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/faces-config.xml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/faces-config.xml Wed Jan 30 09:54:14 2013
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<!DOCTYPE faces-config PUBLIC
+ "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
+ "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
+
+<faces-config>
+
+ <application>
+ <locale-config>
+ <default-locale>en_US</default-locale>
+ <supported-locale>de</supported-locale>
+ <supported-locale>en_GB</supported-locale>
+ <supported-locale>en_US</supported-locale>
+ </locale-config>
+ <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
+ <action-listener>org.apache.myfaces.tobago.util.DebugActionListener</action-listener>
+ <navigation-handler>org.apache.myfaces.tobago.util.DebugNavigationHandler</navigation-handler>
+ <message-bundle>error.messages</message-bundle>
+ </application>
+
+ <lifecycle>
+ <phase-listener>org.apache.myfaces.tobago.util.DebugPhaseListener</phase-listener>
+ <phase-listener>org.apache.myfaces.tobago.example.addressbook.web.StartupPhaseListener</phase-listener>
+ </lifecycle>
+
+ <converter>
+ <converter-for-class>java.util.Locale</converter-for-class>
+ <converter-class>org.apache.myfaces.tobago.example.addressbook.web.LocaleConverter</converter-class>
+ </converter>
+
+ <validator>
+ <validator-id>EmailAddressValidator</validator-id>
+ <validator-class>org.apache.myfaces.tobago.example.addressbook.web.EmailAddressValidator</validator-class>
+ </validator>
+
+ <converter>
+ <converter-for-class>org.apache.myfaces.tobago.example.addressbook.EmailAddress</converter-for-class>
+ <converter-class>org.apache.myfaces.tobago.example.addressbook.web.EmailAddressConverter</converter-class>
+ </converter>
+
+ <navigation-rule>
+ <navigation-case>
+ <from-outcome>editor</from-outcome>
+ <to-view-id>/addressbook/editor.xhtml</to-view-id>
+ </navigation-case>
+ <navigation-case>
+ <from-outcome>list</from-outcome>
+ <to-view-id>/addressbook/list.xhtml</to-view-id>
+ </navigation-case>
+ <navigation-case>
+ <from-outcome>admin</from-outcome>
+ <to-view-id>/addressbook/admin/admin.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
+ <navigation-rule>
+ <navigation-case>
+ <from-outcome>logout</from-outcome>
+ <to-view-id>/auth/logout.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
+</faces-config>
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/tobago-config.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/tobago-config.xml?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/tobago-config.xml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/tobago-config.xml Wed Jan 30 09:54:14 2013
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<!DOCTYPE tobago-config PUBLIC
+ "-//The Apache Software Foundation//DTD Tobago Config 1.0//EN"
+ "http://myfaces.apache.org/tobago/tobago-config_1_0.dtd">
+
+<tobago-config>
+
+ <theme-config>
+ <default-theme>speyside</default-theme>
+ <supported-theme>scarborough</supported-theme>
+ <supported-theme>richmond</supported-theme>
+ <supported-theme>charlotteville</supported-theme>
+ </theme-config>
+
+ <resource-dir>addressbook-resource</resource-dir>
+ <renderers>
+ <renderer>
+ <name>Progress</name>
+ <supported-markup>
+ <markup>ok</markup>
+ <markup>warn</markup>
+ <markup>error</markup>
+ </supported-markup>
+ </renderer>
+ </renderers>
+</tobago-config>
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/web.xml?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/web.xml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/WEB-INF/web.xml Wed Jan 30 09:54:14 2013
@@ -0,0 +1,223 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <display-name>A simple addressbook demo with Tobago</display-name>
+
+ <context-param>
+ <param-name>javax.faces.PROJECT_STAGE</param-name>
+<!--
+ <param-value>Development</param-value>
+-->
+ <param-value>Production</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>facelets.DEVELOPMENT</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>facelets.SKIP_COMMENTS</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>facelets.RESOURCE_RESOLVER</param-name>
+ <param-value>org.apache.myfaces.tobago.facelets.MetaInfResourcesClasspathResourceResolver</param-value>
+ </context-param>
+
+ <context-param>
+ <description>For backward compatibility (using "old" Facelets with JSF 2.0)</description>
+ <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.xhtml</param-value>
+ </context-param>
+
+ <!-- workaround for a bug in Oracle AS (e.g. 10.1.2.0.0)-->
+<!--
+ <listener>
+ <listener-class>org.apache.myfaces.tobago.webapp.TobagoServletContextListener</listener-class>
+ </listener>
+-->
+
+ <listener>
+ <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
+ </listener>
+
+ <listener>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
+
+ <listener>
+ <listener-class>org.apache.myfaces.tobago.example.addressbook.DerbyShutdownServletContextListener</listener-class>
+ </listener>
+
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>/WEB-INF/applicationContext.xml</param-value>
+ </context-param>
+
+ <listener>
+ <listener-class>org.apache.webbeans.servlet.WebBeansConfigurationListener</listener-class>
+ </listener>
+
+ <!-- this is an alternative to the WebBeansConfigurationListener
+ you need it e.g. for Tomcat 5.5 or WebSphere 6.1 (see TOBAGO-1043)
+ -->
+<!--
+ <filter>
+ <filter-name>webbeans</filter-name>
+ <filter-class>org.apache.webbeans.servlet.WebBeansConfigurationFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>webbeans</filter-name>
+ <servlet-name>FacesServlet</servlet-name>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>ERROR</dispatcher>
+ </filter-mapping>
+
+ <listener>
+ <listener-class>org.apache.webbeans.servlet.WebBeansConfigurationHttpSessionListener</listener-class>
+ </listener>
+-->
+
+ <listener>
+ <listener-class>org.apacheExtras.myfaces.codi.addon.openwebbeans.startup.OpenWebBeansAwareConfigurationListener</listener-class>
+ </listener>
+
+ <!-- servlet -->
+
+ <servlet>
+ <servlet-name>FacesServlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet>
+ <servlet-name>PictureServlet</servlet-name>
+ <servlet-class>org.apache.myfaces.tobago.example.addressbook.web.PictureServlet</servlet-class>
+ </servlet>
+
+ <!-- workaround for a bug in Bea Weblogic 8.1 SP 2 and older -->
+ <servlet>
+ <servlet-name>WeblogicWorkaroundServlet</servlet-name>
+ <servlet-class>org.apache.myfaces.tobago.webapp.WeblogicWorkaroundServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet>
+ <servlet-name>ResourceServlet</servlet-name>
+ <servlet-class>org.apache.myfaces.tobago.servlet.ResourceServlet</servlet-class>
+ <init-param>
+ <description>Include the WEB-INF/resources directory from the classpath as root for resources.</description>
+ <param-name>include-webinf-resources</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ </servlet>
+
+ <servlet>
+ <servlet-name>KillSessionServlet</servlet-name>
+ <servlet-class>org.apache.myfaces.tobago.example.addressbook.KillSession</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>KillSessionServlet</servlet-name>
+ <url-pattern>/KillSession</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>FacesServlet</servlet-name>
+ <url-pattern>/faces/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>PictureServlet</servlet-name>
+ <url-pattern>/faces/picture</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>ResourceServlet</servlet-name>
+ <url-pattern>/org/apache/myfaces/tobago/renderkit/*</url-pattern>
+ </servlet-mapping>
+
+ <!--servlet-mapping>
+ <servlet-name>ResourceServlet</servlet-name>
+ <url-pattern>/addressbook-resource/*</url-pattern>
+ </servlet-mapping-->
+
+ <!--servlet-mapping>
+ <servlet-name>ResourceServlet</servlet-name>
+ <url-pattern>/org/tango-project/*</url-pattern>
+ </servlet-mapping-->
+
+ <!-- Welcome File List -->
+
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+
+ <security-constraint>
+ <display-name>Security Constraint</display-name>
+ <web-resource-collection>
+ <web-resource-name>Application Area</web-resource-name>
+ <url-pattern>/faces/addressbook/*</url-pattern>
+ <url-pattern>/addressbook/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>*</role-name>
+ </auth-constraint>
+ </security-constraint>
+
+ <login-config>
+ <auth-method>FORM</auth-method>
+ <realm-name>addressbook-realm</realm-name>
+ <form-login-config>
+ <form-login-page>/faces/auth/login.xhtml</form-login-page>
+ <form-error-page>/faces/auth/error.xhtml</form-error-page>
+ </form-login-config>
+ </login-config>
+
+ <security-role>
+ <role-name>addressbook-user</role-name>
+ </security-role>
+
+ <env-entry>
+ <description>
+ Set the size limit for uploaded files. Default value is 1 MB.
+ Format: 10 = 10 bytes
+ 10k = 10 KB
+ 10m = 10 MB
+ 1g = 1 GB
+ </description>
+ <env-entry-name>uploadMaxFileSize</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>1m</env-entry-value>
+ </env-entry>
+
+</web-app>
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/scarborough/standard/style/tobago.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/scarborough/standard/style/tobago.css?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/scarborough/standard/style/tobago.css (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/scarborough/standard/style/tobago.css Wed Jan 30 09:54:14 2013
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+.tobago-progress-value-markup-ok {
+ background: green;
+}
+
+.tobago-progress-value-markup-warn {
+ background: yellow;
+}
+
+.tobago-progress-value-markup-error {
+ background: red;
+}
+
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/speyside/standard/style/tobago.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/speyside/standard/style/tobago.css?rev=1440322&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/speyside/standard/style/tobago.css (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/speyside/standard/style/tobago.css Wed Jan 30 09:54:14 2013
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+.tobago-progress-value-markup-ok {
+ background: green;
+}
+
+.tobago-progress-value-markup-warn {
+ background: yellow;
+}
+
+.tobago-progress-value-markup-error {
+ background: red;
+}
+
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/addressbook/icon/flag-de.png
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/addressbook/icon/flag-de.png?rev=1440322&view=auto
==============================================================================
Binary file - no diff available.
Propchange: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/addressbook/icon/flag-de.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/addressbook/icon/flag-gb.png
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/addressbook/icon/flag-gb.png?rev=1440322&view=auto
==============================================================================
Binary file - no diff available.
Propchange: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/addressbook/icon/flag-gb.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/addressbook/icon/flag-us.png
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/addressbook/icon/flag-us.png?rev=1440322&view=auto
==============================================================================
Binary file - no diff available.
Propchange: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/addressbook/icon/flag-us.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/empty-portrait.png
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/empty-portrait.png?rev=1440322&view=auto
==============================================================================
Binary file - no diff available.
Propchange: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/empty-portrait.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/empty-portrait_de.png
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/empty-portrait_de.png?rev=1440322&view=auto
==============================================================================
Binary file - no diff available.
Propchange: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/empty-portrait_de.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/16x16/categories/preferences-systemDisabled.png
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/16x16/categories/preferences-systemDisabled.png?rev=1440322&view=auto
==============================================================================
Binary file - no diff available.
Propchange: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/16x16/categories/preferences-systemDisabled.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/32x32/categories/preferences-systemDisabled.png
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/32x32/categories/preferences-systemDisabled.png?rev=1440322&view=auto
==============================================================================
Binary file - no diff available.
Propchange: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/32x32/categories/preferences-systemDisabled.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/32x32/mimetypes/x-office-address-bookDisabled.png
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/32x32/mimetypes/x-office-address-bookDisabled.png?rev=1440322&view=auto
==============================================================================
Binary file - no diff available.
Propchange: myfaces/tobago/trunk/tobago-example/tobago-example-addressbook-cdi/src/main/webapp/addressbook-resource/html/standard/standard/image/org/tango-project/tango-icon-theme/32x32/mimetypes/x-office-address-bookDisabled.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream