moved to sub projects
This commit is contained in:
parent
a523cc9122
commit
dff60035cf
182 changed files with 251 additions and 46 deletions
11
vasc-frontends/vasc-frontend-web-jsf/.classpath
Normal file
11
vasc-frontends/vasc-frontend-web-jsf/.classpath
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
29
vasc-frontends/vasc-frontend-web-jsf/.project
Normal file
29
vasc-frontends/vasc-frontend-web-jsf/.project
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>vasc-frontend-web-jsf</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.maven.ide.eclipse.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.maven.ide.eclipse.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#Sun Dec 25 17:29:07 CET 2011
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding//src/test/resources=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#Mon Aug 30 21:58:06 CEST 2010
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
org.eclipse.jdt.core.compiler.compliance=1.5
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.5
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#Sun Dec 25 17:29:03 CET 2011
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#Mon Aug 30 21:58:05 CEST 2010
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
fullBuildGoals=process-test-resources
|
||||
includeModules=false
|
||||
resolveWorkspaceProjects=true
|
||||
resourceFilterGoals=process-resources resources\:testResources
|
||||
skipCompilerPlugin=true
|
||||
version=1
|
||||
67
vasc-frontends/vasc-frontend-web-jsf/pom.xml
Normal file
67
vasc-frontends/vasc-frontend-web-jsf/pom.xml
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>vasc-frontends</artifactId>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<version>0.3.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<artifactId>vasc-frontend-web-jsf</artifactId>
|
||||
<version>0.3.5-SNAPSHOT</version>
|
||||
<name>vasc-frontend-web-jsf</name>
|
||||
<description>vasc-frontend-web-jsf</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<artifactId>vasc-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.forwardfire.vasc</groupId>
|
||||
<artifactId>vasc-ejb3</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.faces</groupId>
|
||||
<artifactId>jsf-api</artifactId>
|
||||
<version>1.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>jstl</artifactId>
|
||||
<version>1.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet.jsp</groupId>
|
||||
<artifactId>jsp-api</artifactId>
|
||||
<version>2.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.faces</groupId>
|
||||
<artifactId>jsf-impl</artifactId>
|
||||
<version>1.2_04</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- tomahak jsf frontend
|
||||
<dependency>
|
||||
<groupId>org.apache.myfaces.tomahawk</groupId>
|
||||
<artifactId>tomahawk12</artifactId>
|
||||
<version>1.1.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,455 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.web.jsf;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
|
||||
import net.forwardfire.vasc.core.VascBackend;
|
||||
import net.forwardfire.vasc.core.VascBackendControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascBackendState;
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryControllerLocal;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.VascFrontendData;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryBackendEventListener;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryRecordCreator;
|
||||
import net.forwardfire.vasc.ejb3.VascServiceManager;
|
||||
import net.forwardfire.vasc.impl.DefaultVascBackedEntryFinalizer;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
import net.forwardfire.vasc.impl.VascBackendProxyEventExecutor;
|
||||
import net.forwardfire.vasc.impl.entry.DefaultVascEntryResourceResolver;
|
||||
import net.forwardfire.vasc.impl.entry.SetParameterBackendListener;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Base faces session object for managing vasc entries.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Sep 21, 2010
|
||||
*/
|
||||
abstract public class AbstractJSFVascFacesController {
|
||||
|
||||
private VascController vascController = null;
|
||||
|
||||
abstract public String getVascSericeManagerJNDI();
|
||||
abstract public String getResourceBundleWEB();
|
||||
abstract public boolean getDisableI18N();
|
||||
abstract public VascUserInfo getVascUserInfo();
|
||||
|
||||
public class VascUserInfo {
|
||||
Long userId;
|
||||
String username;
|
||||
String[] roles;
|
||||
public VascUserInfo(Long userId,String username,String[] roles) {
|
||||
this.userId=userId;
|
||||
this.username=username;
|
||||
this.roles=roles;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
class RefreshObjectForLazyPropertiesListener implements VascEntryFrontendEventListener {
|
||||
public VascFrontendEventType[] getEventTypes() {
|
||||
VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.POST_UPDATE};
|
||||
return result;
|
||||
}
|
||||
public void vascEvent(VascEntry entry,Object data) {
|
||||
if (data.getClass().getName().startsWith("some.class.models.jpa")==false) {
|
||||
return; // only refresh model classes
|
||||
}
|
||||
|
||||
// TODO: mmm rewrite events to change to different object to use ejb3++ solution ?
|
||||
// Use hiberbate session to attach a detected object again. (note: this is not possible with EJB3, uses merge() which returns a new object)
|
||||
//((Session)entityManager.getDelegate()).refresh(data);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
class MergedResourceBundle extends ResourceBundle {
|
||||
Map<String,String> data = new HashMap<String,String>(500);
|
||||
|
||||
public void addDateMap(Map<String,String> dataMap) {
|
||||
data.putAll(dataMap);
|
||||
}
|
||||
public void addDataBundle(ResourceBundle bundle) {
|
||||
for (String key:bundle.keySet()) {
|
||||
String value = bundle.getString(key);
|
||||
data.put(key, value);
|
||||
}
|
||||
}
|
||||
public Object handleGetObject(String key) {
|
||||
return data.get(key);
|
||||
}
|
||||
|
||||
public Enumeration<String> getKeys() {
|
||||
return Collections.enumeration(data.keySet());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Config vasc frontend data object for jsf component to use.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public VascFrontendData getNewVascFrontendData() {
|
||||
Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
|
||||
MergedResourceBundle bundle = new MergedResourceBundle();
|
||||
bundle.addDataBundle(ResourceBundle.getBundle(getResourceBundleWEB(), locale));
|
||||
|
||||
try {
|
||||
Context context = new InitialContext();
|
||||
VascServiceManager vascManager = (VascServiceManager)context.lookup(getVascSericeManagerJNDI());
|
||||
Map<String,String> remoteI18n = vascManager.getResourceBundle(locale.toString());
|
||||
bundle.addDateMap(remoteI18n);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not get the ejb resource bundle: "+e.getMessage(),e);
|
||||
}
|
||||
|
||||
VascFrontendData vascFrontendData = DefaultVascFactory.getDefaultVascFrontendData(bundle);
|
||||
vascFrontendData.addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public VascFrontendEventType[] getEventTypes() {
|
||||
VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.EXCEPTION};
|
||||
return result;
|
||||
}
|
||||
public void vascEvent(VascEntry entry, Object data) {
|
||||
if (data instanceof Exception) {
|
||||
((Exception)data).printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// config frontend data for ISF usage
|
||||
if (getDisableI18N()) {
|
||||
vascFrontendData.setVascEntryResourceResolver(new DefaultVascEntryResourceResolver());
|
||||
} else {
|
||||
vascFrontendData.setVascEntryResourceResolver(new DefaultVascEntryResourceResolver(bundle));
|
||||
}
|
||||
return vascFrontendData;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public List<Object> executeVascList(String entryId,Map<String,Object> para) {
|
||||
try {
|
||||
// plug all object
|
||||
VascEntry entry = getVascController().getVascEntryController().getVascEntryById(entryId);
|
||||
entry.setVascFrontendData(getNewVascFrontendData());
|
||||
entry.getVascFrontendData().setVascController(getVascController());
|
||||
VascBackend backend = DefaultVascFactory.getProxyVascBackend(entry);
|
||||
entry.getVascFrontendData().getVascEntryState().setVascBackend(backend);
|
||||
entry.getVascFrontendData().getVascEntryState().setVascEntry(entry);
|
||||
|
||||
// set def para
|
||||
VascBackendState state = entry.getVascFrontendData().getVascEntryState().getVascBackendState();
|
||||
for (String key2:entry.getEntryParameterKeys()) {
|
||||
Object value = entry.getEntryParameter(key2);
|
||||
//System.out.println("Copy paras name: "+key2+" value: "+value+" class: "+value.getClass().getName());
|
||||
state.setDataParameter(key2, value);
|
||||
}
|
||||
|
||||
// set list para
|
||||
for (VascEntryField vef:entry.getListOptions()) {
|
||||
Object def = vef.getDefaultValue();
|
||||
if (def==null) {
|
||||
continue;
|
||||
}
|
||||
String backendName = vef.getBackendName();
|
||||
state.setDataParameter(backendName, def);
|
||||
}
|
||||
|
||||
// copy para
|
||||
if (para!=null) {
|
||||
for (String key:para.keySet()) {
|
||||
entry.setEntryParameter(key, para.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
// done, execute and return data.
|
||||
entry.getVascFrontendData().getVascFrontendHelper().refreshData(entry);
|
||||
return entry.getVascFrontendData().getVascEntryState().getEntryDataList();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not execute list: "+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
class RemoteVascBackend implements VascBackend {
|
||||
|
||||
private String backendId = null;
|
||||
private VascServiceManager vascManager = null;
|
||||
|
||||
public RemoteVascBackend(String backendId,VascServiceManager vascManager) {
|
||||
this.backendId=backendId;
|
||||
this.vascManager=vascManager;
|
||||
}
|
||||
|
||||
public void delete(Object object) throws VascException {
|
||||
Object[] args = new Object[1];
|
||||
args[0]=object;
|
||||
vascManager.invokeBackendMethod(backendId, "delete", args);
|
||||
}
|
||||
|
||||
public long doRecordMoveDownById(VascBackendState state,Object primaryId) throws VascException {
|
||||
Object[] args = new Object[2];
|
||||
args[0]=state;
|
||||
args[1]=primaryId;
|
||||
Object result = vascManager.invokeBackendMethod(backendId, "doRecordMoveDownById", args);
|
||||
return (Long)result;
|
||||
}
|
||||
|
||||
public long doRecordMoveUpById(VascBackendState state, Object primaryId) throws VascException {
|
||||
Object[] args = new Object[2];
|
||||
args[0]=state;
|
||||
args[1]=primaryId;
|
||||
Object result = vascManager.invokeBackendMethod(backendId, "doRecordMoveUpById", args);
|
||||
return (Long)result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Object> execute(VascBackendState state) throws VascException {
|
||||
Object[] args = new Object[1];
|
||||
args[0]=state;
|
||||
Object result = vascManager.invokeBackendMethod(backendId, "execute", args);
|
||||
return (List<Object>)result;
|
||||
}
|
||||
|
||||
public long fetchTotalExecuteSize(VascBackendState state) {
|
||||
Object[] args = new Object[1];
|
||||
args[0]=state;
|
||||
Object result = vascManager.invokeBackendMethod(backendId, "fetchTotalExecuteSize", args);
|
||||
return (Long)result;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return backendId;
|
||||
}
|
||||
|
||||
public boolean isPageable() {
|
||||
Object[] args = new Object[0];
|
||||
Object result = vascManager.invokeBackendMethod(backendId, "isPageable", args);
|
||||
return (Boolean)result;
|
||||
}
|
||||
|
||||
public boolean isRecordMoveable() {
|
||||
Object[] args = new Object[0];
|
||||
Object result = vascManager.invokeBackendMethod(backendId, "isRecordMoveable", args);
|
||||
return (Boolean)result;
|
||||
}
|
||||
|
||||
public boolean isSearchable() {
|
||||
Object[] args = new Object[0];
|
||||
Object result = vascManager.invokeBackendMethod(backendId, "isSearchable", args);
|
||||
return (Boolean)result;
|
||||
}
|
||||
|
||||
public boolean isSortable() {
|
||||
Object[] args = new Object[0];
|
||||
Object result = vascManager.invokeBackendMethod(backendId, "isSortable", args);
|
||||
return (Boolean)result;
|
||||
}
|
||||
|
||||
public Object merge(Object object) throws VascException {
|
||||
Object[] args = new Object[1];
|
||||
args[0]=object;
|
||||
Object result = vascManager.invokeBackendMethod(backendId, "merge", args);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void persist(Object object) throws VascException {
|
||||
Object[] args = new Object[1];
|
||||
args[0]=object;
|
||||
vascManager.invokeBackendMethod(backendId, "delete", args);
|
||||
}
|
||||
|
||||
public VascEntryFieldValue provideVascEntryFieldValue(VascEntryField field) {
|
||||
/*
|
||||
try {
|
||||
ByteArrayOutputStream dataArray = new ByteArrayOutputStream(256); // it grows when needed
|
||||
ObjectOutputStream objOutstream = new ObjectOutputStream(dataArray);
|
||||
objOutstream.writeObject(field);
|
||||
objOutstream.close();
|
||||
int objectSize = dataArray.size();
|
||||
System.out.println("Writing obj to field: "+objectSize);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
*/
|
||||
Object[] args = new Object[1];
|
||||
args[0]=field;
|
||||
Object result = vascManager.invokeBackendMethod(backendId, "provideVascEntryFieldValue", args);
|
||||
return (VascEntryFieldValue)result;
|
||||
}
|
||||
|
||||
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
|
||||
VascEntry clone = null;
|
||||
try {
|
||||
clone = vascEntry.clone();
|
||||
clone.setVascFrontendData(null);
|
||||
clone.setVascEntryFieldEventChannel(null);
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
ByteArrayOutputStream dataArray = new ByteArrayOutputStream(256); // it grows when needed
|
||||
ObjectOutputStream objOutstream = new ObjectOutputStream(dataArray);
|
||||
objOutstream.writeObject(clone);
|
||||
objOutstream.close();
|
||||
//int objectSize = dataArray.size();
|
||||
//System.out.println("Writing obj to entry: "+objectSize);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Object[] args = new Object[1];
|
||||
args[0]=clone;
|
||||
Object result = vascManager.invokeBackendMethod(backendId, "provideVascEntryRecordCreator", args);
|
||||
return (VascEntryRecordCreator)result;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
// we cant change id
|
||||
}
|
||||
|
||||
public Map<String, Object> executePageSummary() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map<String, Object> executeTotalSummary() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isPageSummary() {
|
||||
Object[] args = new Object[0];
|
||||
Object result = vascManager.invokeBackendMethod(backendId, "isPageSummary", args);
|
||||
return (Boolean)result;
|
||||
}
|
||||
|
||||
public boolean isTotalSummary() {
|
||||
Object[] args = new Object[0];
|
||||
Object result = vascManager.invokeBackendMethod(backendId, "isTotalSummary", args);
|
||||
return (Boolean)result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascController
|
||||
*/
|
||||
public VascController getVascController() {
|
||||
if (vascController!=null) {
|
||||
return vascController;
|
||||
}
|
||||
try {
|
||||
VascUserInfo vui = getVascUserInfo();
|
||||
|
||||
|
||||
// get local jvm plugging controller
|
||||
VascController c = DefaultVascFactory.getDefaultVascController(vui.userId, vui.username, vui.roles);
|
||||
|
||||
/*
|
||||
DefaultVascEntryController con = new DefaultVascEntryController() {
|
||||
public VascEntry getVascEntryById(String id) {
|
||||
VascEntry ve = super.getVascEntryById(id);
|
||||
// add global listener to make sure we have all LAZY properties of a bean before we goto edit mode.
|
||||
ve.addVascEntryEventListener(VascEventType.DATA_SELECT, new RefreshObjectForLazyPropertiesListener());
|
||||
return ve;
|
||||
}
|
||||
};
|
||||
((DefaultVascController)c).setVascEntryController(con);
|
||||
*/
|
||||
|
||||
Context context = new InitialContext();
|
||||
VascServiceManager vascManager = (VascServiceManager)context.lookup(getVascSericeManagerJNDI());
|
||||
List<String> entryIds = vascManager.getVascEntryIds();
|
||||
|
||||
VascEntryControllerLocal localEntryController = (VascEntryControllerLocal)c.getVascEntryController();
|
||||
VascBackendControllerLocal localBackendController = (VascBackendControllerLocal)c.getVascBackendController();
|
||||
for (String id:entryIds) {
|
||||
VascEntry ve = vascManager.getVascEntry(id);
|
||||
String backendId = ve.getBackendId();
|
||||
VascBackend vb = new RemoteVascBackend(backendId,vascManager);
|
||||
|
||||
for (String key:ve.getEntryParameterKeys()) {
|
||||
Object value = ve.getEntryParameter(key);
|
||||
if (value instanceof String==false) {
|
||||
continue;
|
||||
}
|
||||
String paraValue = (String)value;
|
||||
if (paraValue.startsWith("userPara")==false) {
|
||||
continue;
|
||||
}
|
||||
String[] ps = paraValue.split(":");
|
||||
String type = ps[1];
|
||||
String paraTypeValue = ps[2];
|
||||
|
||||
SetParameterBackendListener listener = new SetParameterBackendListener(vui.userId,vui.username);
|
||||
listener.setName(key);
|
||||
listener.setType(type);
|
||||
listener.setValue(paraTypeValue);
|
||||
|
||||
List<VascEntryBackendEventListener> listeners=new ArrayList<VascEntryBackendEventListener>(10);
|
||||
listeners.add(listener);
|
||||
vb = new VascBackendProxyEventExecutor(vb,ve,listeners);
|
||||
}
|
||||
|
||||
|
||||
localBackendController.addVascBackend(vb);
|
||||
|
||||
DefaultVascBackedEntryFinalizer f = new DefaultVascBackedEntryFinalizer();
|
||||
ve = f.finalizeVascEntry(ve,c);
|
||||
|
||||
localEntryController.addVascEntry(ve, c);
|
||||
}
|
||||
vascController = c;
|
||||
return vascController;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not create remote based vasc controller; "+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setVascController(VascController vascController) {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package net.forwardfire.vasc.frontends.web.jsf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.el.ValueExpression;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author willemc
|
||||
*
|
||||
*/
|
||||
public class JSFVascEntryEventListener implements VascEntryFrontendEventListener {
|
||||
|
||||
private static final long serialVersionUID = 1765054259934158076L;
|
||||
private String entrySupportVar = null;
|
||||
|
||||
public JSFVascEntryEventListener(String entrySupportVar) {
|
||||
this.entrySupportVar=entrySupportVar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener#getEventTypes()
|
||||
*/
|
||||
public VascFrontendEventType[] getEventTypes() {
|
||||
VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.POST_READ};
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void vascEvent(VascEntry entry,Object dataNotUsed) {
|
||||
try {
|
||||
for (VascEntryField field:entry.getVascEntryFields()) {
|
||||
if (field.getVascEntryFieldValue()==null) {
|
||||
// TODO: fix this for better remote support
|
||||
VascEntryField fieldClone = field.clone();
|
||||
fieldClone.getVascValidators().clear();
|
||||
|
||||
VascEntryFieldValue v = entry.getVascFrontendData().getVascEntryState().getVascBackend().provideVascEntryFieldValue(fieldClone);
|
||||
field.setVascEntryFieldValue(v);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
List<Object> data = entry.getVascFrontendData().getVascEntryState().getEntryDataList();
|
||||
List<Object> result = new ArrayList<Object>(data.size());
|
||||
int index = 0;
|
||||
for (Object o:data) {
|
||||
VascDataBackendBean b = new VascDataBackendBean(entry,o,index);
|
||||
result.add(b);
|
||||
index++;
|
||||
}
|
||||
|
||||
ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".tableDataModel.wrappedData}", Object.class);
|
||||
ve2.setValue(FacesContext.getCurrentInstance().getELContext(), result);
|
||||
ValueExpression ve3 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".tablePagesDataModel.wrappedData}", Object.class);
|
||||
ve3.setValue(FacesContext.getCurrentInstance().getELContext(), entry.getVascFrontendData().getVascFrontendHelper().getVascBackendPageNumbers(entry));
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.web.jsf;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import net.forwardfire.vasc.core.AbstractVascFrontend;
|
||||
import net.forwardfire.vasc.core.VascFrontendData;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryExporter;
|
||||
import net.forwardfire.vasc.frontends.web.jsf.ui.JSFBoolean;
|
||||
import net.forwardfire.vasc.frontends.web.jsf.ui.JSFLabel;
|
||||
import net.forwardfire.vasc.frontends.web.jsf.ui.JSFList;
|
||||
import net.forwardfire.vasc.frontends.web.jsf.ui.JSFText;
|
||||
import net.forwardfire.vasc.frontends.web.jsf.ui.JSFTextArea;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Given the jsf vasc renderer its own class
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 12, 2009
|
||||
*/
|
||||
public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Logger logger = null;
|
||||
|
||||
public JSFVascFrontendRenderer() {
|
||||
logger = Logger.getLogger(JSFVascFrontendRenderer.class.getName());
|
||||
}
|
||||
|
||||
// Frontend Stuff
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascFrontend#getFrontendType()
|
||||
*/
|
||||
public String getFrontendType() {
|
||||
return "jsf";
|
||||
}
|
||||
|
||||
|
||||
protected void addUiComponents() {
|
||||
VascFrontendData vfd = getVascEntry().getVascFrontendData();
|
||||
|
||||
// required UI components
|
||||
vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_LABEL,JSFLabel.class.getName());
|
||||
vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_TEXT, JSFText.class.getName());
|
||||
vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_LIST, JSFList.class.getName());
|
||||
//vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_BUTTON, JSFButton.class.getName());
|
||||
|
||||
// optional UI components
|
||||
vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_BOOLEAN , JSFBoolean.class.getName());
|
||||
//vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_DATE , JSFDate.class.getName());
|
||||
vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_TEXTAREA , JSFTextArea.class.getName());
|
||||
//vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_COLOR , JSFColorChooser.class.getName());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascFrontend#renderDelete(java.lang.Object)
|
||||
*/
|
||||
public void renderDelete() throws Exception {
|
||||
logger.finer("renderDelete");
|
||||
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
|
||||
JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,getVascEntry().getId());
|
||||
comp.setRenderFacetState("deleteView");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascFrontend#renderEdit(java.lang.Object)
|
||||
*/
|
||||
public void renderEdit() throws Exception {
|
||||
logger.finer("renderEdit");
|
||||
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
|
||||
JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,getVascEntry().getId());
|
||||
comp.setRenderFacetState("editView");
|
||||
entry.getVascFrontendData().getVascFrontendHelper().editReadOnlyUIComponents(entry);
|
||||
|
||||
VascDataBackendBean selBean = null;
|
||||
if (entry.getVascFrontendData().getVascEntryState().isEditCreate()) {
|
||||
int index = entry.getVascFrontendData().getVascEntryState().getEntryDataList().size()+1;
|
||||
selBean = new VascDataBackendBean(entry,entry.getVascFrontendData().getVascEntryState().getEntryDataObject(),index);
|
||||
} else {
|
||||
selBean = comp.getSupportBean().getSelectedTableRecord();
|
||||
}
|
||||
selBean.setRealValue(true);
|
||||
|
||||
comp.getSupportBean().setSelected(selBean);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascFrontend#renderExport(net.forwardfire.vasc.core.entry.VascEntryExporter)
|
||||
*/
|
||||
public void renderExport(VascEntryExporter exporter) throws Exception {
|
||||
logger.finer("renderExport");
|
||||
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
|
||||
JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,getVascEntry().getId());
|
||||
comp.setRenderFacetState("exportView");
|
||||
comp.getSupportBean().setSelectedExporter(exporter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.VascFrontend#renderView()
|
||||
*/
|
||||
public void renderView() throws Exception {
|
||||
logger.finer("renderView");
|
||||
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
|
||||
JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,getVascEntry().getId());
|
||||
comp.setRenderFacetState("listView");
|
||||
|
||||
//if (comp.getSupportBean().getSelected()!=null) {
|
||||
// comp.getSupportBean().getSelected().setRealValue(false);
|
||||
// comp.getSupportBean().setSelected(null);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,444 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.web.jsf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.el.ValueExpression;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIComponentBase;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import net.forwardfire.vasc.core.VascBackend;
|
||||
import net.forwardfire.vasc.core.VascController;
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascEntryState;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.VascFrontendData;
|
||||
import net.forwardfire.vasc.core.VascLinkEntry;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType;
|
||||
import net.forwardfire.vasc.frontends.web.jsf.ui.JSFListModel;
|
||||
import net.forwardfire.vasc.impl.DefaultVascFactory;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Renders an JSF vasc entry views.
|
||||
*
|
||||
* This is a already less hacky this is second incarnation of this bean
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 16, 2008
|
||||
*/
|
||||
public class JSFVascUIComponent extends UIComponentBase {
|
||||
|
||||
public static final String FAMILY = "vasc.jsf.component.family";
|
||||
public static final String VASC_CONTROLLER_KEY = "vascController";
|
||||
public static final String VASC_FRONTEND_DATA_KEY = "vascFrontendData";
|
||||
public static final String ENTRY_NAME_KEY = "entryName";
|
||||
public static final String ENTRY_SUPPORT_VAR_KEY = "entrySupportVar";
|
||||
public static final String TABLE_RECORD_VAR_KEY = "tableRecordVar";
|
||||
public static final String INJECT_EDIT_FIELDS_ID = "injectEditFieldsId";
|
||||
public static final String INJECT_TABLE_OPTIONS_ID = "injectTableOptionsId";
|
||||
public static final String INJECT_TABLE_COLUMNS_ID = "injectTableColumnsId";
|
||||
public static final String DISABLE_LINK_COLUMNS = "disableLinkColumns";
|
||||
public static final String INJECT_TABLE_OPTIONS_ON_CHANGE = "injectTableOptionOnChange";
|
||||
|
||||
private JSFVascFrontendRenderer renderer = null;
|
||||
private JSFVascEntrySupportBean supportBean = null;
|
||||
private String renderFacetState = null;
|
||||
private VascLinkEntry link = null;
|
||||
private VascEntryState linkState = null;
|
||||
private VascEntryState state = null;
|
||||
private Object stateEditId = null;
|
||||
private Logger logger = null;
|
||||
private Boolean initClear = null;
|
||||
private String injectTableOptionOnChange = null;
|
||||
|
||||
public JSFVascUIComponent() {
|
||||
logger = Logger.getLogger(JSFVascUIComponent.class.getName());
|
||||
}
|
||||
|
||||
public String getFamily() {
|
||||
return FAMILY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object saveState(FacesContext facesContext) {
|
||||
logger.fine("Save State");
|
||||
Object values[] = new Object[8];
|
||||
values[0] = super.saveState(facesContext);
|
||||
values[1] = this.getAttributes().get(VASC_CONTROLLER_KEY);
|
||||
values[2] = this.getAttributes().get(VASC_FRONTEND_DATA_KEY);
|
||||
values[3] = this.getAttributes().get(ENTRY_NAME_KEY);
|
||||
values[4] = renderer;
|
||||
values[5] = supportBean;
|
||||
values[6] = renderFacetState;
|
||||
values[7] = this.getAttributes().get(INJECT_TABLE_OPTIONS_ON_CHANGE);
|
||||
return values;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreState(FacesContext facesContext, Object state) {
|
||||
logger.fine("Resotre State");
|
||||
Object values[] = (Object[])state;
|
||||
super.restoreState(facesContext, values[0]);
|
||||
this.getAttributes().put(VASC_CONTROLLER_KEY, values[1]);
|
||||
this.getAttributes().put(VASC_FRONTEND_DATA_KEY, values[2]);
|
||||
this.getAttributes().put(ENTRY_NAME_KEY, values[3]);
|
||||
renderer = (JSFVascFrontendRenderer) values[4];
|
||||
supportBean = (JSFVascEntrySupportBean) values[5];
|
||||
renderFacetState = (String) values[6];
|
||||
injectTableOptionOnChange = (String) values[7];
|
||||
|
||||
// TODO: check if we can move this some day...
|
||||
String entrySupportVar = (String)getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
|
||||
ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+"}", Object.class);
|
||||
ve2.setValue(FacesContext.getCurrentInstance().getELContext(), getSupportBean());
|
||||
}
|
||||
|
||||
static public JSFVascUIComponent findVascParent(UIComponent comp) {
|
||||
if (comp==null) {
|
||||
return null;
|
||||
}
|
||||
if (comp instanceof JSFVascUIComponent) {
|
||||
return (JSFVascUIComponent)comp;
|
||||
}
|
||||
return findVascParent(comp.getParent());
|
||||
}
|
||||
|
||||
static public JSFVascUIComponent findVascChild(UIComponent comp,String entryId) {
|
||||
if (comp==null) {
|
||||
return null;
|
||||
}
|
||||
if (comp instanceof JSFVascUIComponent) {
|
||||
JSFVascUIComponent ui = (JSFVascUIComponent)comp;
|
||||
if (entryId==null) {
|
||||
return ui;
|
||||
}
|
||||
if (entryId.equals(ui.getVascEntry().getId())) {
|
||||
return ui;
|
||||
}
|
||||
return null; // this is a other entry on this view
|
||||
}
|
||||
for (UIComponent c:comp.getChildren()) {
|
||||
Object res = findVascChild(c,entryId);
|
||||
if (res!=null) {
|
||||
return (JSFVascUIComponent)res; // found
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds component with the given id
|
||||
*/
|
||||
static public UIComponent findComponentById(UIComponent c, String id) {
|
||||
if (id.equals(c.getId())) {
|
||||
return c;
|
||||
}
|
||||
Iterator<UIComponent> kids = c.getFacetsAndChildren();
|
||||
while (kids.hasNext()) {
|
||||
UIComponent found = findComponentById(kids.next(), id);
|
||||
if (found != null) {
|
||||
return found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public VascEntry getVascEntry() {
|
||||
return renderer.getVascEntry();
|
||||
}
|
||||
|
||||
protected void initGoto(VascLinkEntry link) {
|
||||
logger.fine("init goto "+link);
|
||||
this.link=link;
|
||||
}
|
||||
protected void initGoto(VascLinkEntry link,VascEntryState state) {
|
||||
logger.fine("init goto link: "+link);
|
||||
this.link=link;
|
||||
this.linkState=state;
|
||||
}
|
||||
|
||||
protected void initGoto(VascEntryState state) {
|
||||
logger.fine("init goto "+state);
|
||||
this.state=state;
|
||||
}
|
||||
|
||||
protected void initGoto(VascEntryState state,Object stateEditId) {
|
||||
logger.fine("init goto "+state);
|
||||
this.state=state;
|
||||
this.stateEditId=stateEditId;
|
||||
}
|
||||
|
||||
public Boolean getInitClear() {
|
||||
return initClear;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encodeBegin(FacesContext context) throws IOException {
|
||||
logger.fine("Comp encodeBegin link: "+link);
|
||||
// no need to add multiple
|
||||
if (renderer==null) {
|
||||
logger.finer("Adding phase listener: JSFVascValidatePhaseListener");
|
||||
context.getViewRoot().addPhaseListener(new JSFVascValidatePhaseListener());
|
||||
}
|
||||
boolean init = false;
|
||||
if (renderer==null | link!=null | state!=null) {
|
||||
renderFacetState = "listView";
|
||||
VascEntry entry = createClonedVascEntry();
|
||||
renderer = new JSFVascFrontendRenderer();
|
||||
try {
|
||||
renderer.initEntry(entry);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not initEntry: "+e.getMessage(),e);
|
||||
}
|
||||
supportBean = new JSFVascEntrySupportBean(entry);
|
||||
// copy search string for preadded search string from application layer
|
||||
supportBean.setSearchString(entry.getVascFrontendData().getVascEntryState().getVascBackendState().getSearchString());
|
||||
|
||||
init = true;
|
||||
}
|
||||
|
||||
if (stateEditId!=null) {
|
||||
Object rowObject = stateEditId;
|
||||
|
||||
// setup for renderEdit() of frontend
|
||||
List<Object> list = new ArrayList<Object>(1);
|
||||
list.add(new VascDataBackendBean(supportBean.getVascEntry(),rowObject,0));
|
||||
supportBean.getTableDataModel().setWrappedData(list);
|
||||
supportBean.getTableDataModel().setRowIndex(0);
|
||||
|
||||
// edit action copyed
|
||||
try {
|
||||
VascEntry entry = supportBean.getVascEntry();
|
||||
entry.getVascFrontendData().getVascEntryState().setEditCreate(false);
|
||||
entry.getVascFrontendData().getVascFrontendHelper().fireVascEvent(entry, VascFrontendEventType.SELECT, rowObject);
|
||||
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(rowObject);
|
||||
entry.getVascFrontendData().getVascFrontend().renderEdit();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not renderEdit: "+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
// refresh all drop down lists..
|
||||
for (String key:supportBean.getEditSelectItemModels().keySet()) {
|
||||
Object o = supportBean.getEditSelectItemModels().get(key);
|
||||
if (o instanceof JSFListModel) {
|
||||
JSFListModel t = (JSFListModel)o;
|
||||
t.requestRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
// set the support bean
|
||||
String entrySupportVar = (String)getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
|
||||
ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+"}", Object.class);
|
||||
ve2.setValue(FacesContext.getCurrentInstance().getELContext(), getSupportBean());
|
||||
|
||||
// set init for component renderer
|
||||
if (init) {
|
||||
initClear = false;
|
||||
if (link!=null | state!=null) {
|
||||
initClear = true;
|
||||
}
|
||||
}
|
||||
super.encodeBegin(context);
|
||||
}
|
||||
|
||||
public UIComponent getCurrentView() {
|
||||
UIComponent result = getFacet(renderFacetState);
|
||||
if (result==null) {
|
||||
throw new IllegalArgumentException("Could not get facet: "+renderFacetState);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public JSFVascEntrySupportBean getSupportBean() {
|
||||
return supportBean;
|
||||
}
|
||||
|
||||
public void setRenderFacetState(String renderFacetState) {
|
||||
this.renderFacetState=renderFacetState;
|
||||
}
|
||||
|
||||
public String getRenderFacetState() {
|
||||
return renderFacetState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the injectTableOptionOnChange
|
||||
*/
|
||||
public String getInjectTableOptionOnChange() {
|
||||
return injectTableOptionOnChange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param injectTableOptionOnChange the injectTableOptionOnChange to set
|
||||
*/
|
||||
public void setInjectTableOptionOnChange(String injectTableOptionOnChange) {
|
||||
this.injectTableOptionOnChange = injectTableOptionOnChange;
|
||||
}
|
||||
|
||||
public VascEntry createClonedVascEntry() {
|
||||
|
||||
String entryName = null;
|
||||
VascController vascController = null;
|
||||
VascFrontendData frontendData = null;
|
||||
|
||||
if (getAttributes().get(VASC_CONTROLLER_KEY) instanceof String) {
|
||||
// fix for JSP tag handler
|
||||
logger.finer("Getting expression: "+getAttributes().get(VASC_CONTROLLER_KEY));
|
||||
ValueExpression ve1 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), (String)getAttributes().get(VASC_CONTROLLER_KEY), Object.class);
|
||||
ValueExpression ve2 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), (String)getAttributes().get(VASC_FRONTEND_DATA_KEY), Object.class);
|
||||
ValueExpression ve3 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), (String)getAttributes().get(ENTRY_NAME_KEY), String.class);
|
||||
vascController = (VascController)ve1.getValue( FacesContext.getCurrentInstance().getELContext());
|
||||
frontendData = (VascFrontendData)ve2.getValue( FacesContext.getCurrentInstance().getELContext());
|
||||
entryName = (String)ve3.getValue( FacesContext.getCurrentInstance().getELContext());
|
||||
} else {
|
||||
vascController = (VascController)getAttributes().get(VASC_CONTROLLER_KEY);
|
||||
frontendData = (VascFrontendData)getAttributes().get(VASC_FRONTEND_DATA_KEY);
|
||||
entryName = (String)getAttributes().get(ENTRY_NAME_KEY);
|
||||
}
|
||||
|
||||
if (link!=null) {
|
||||
entryName = link.getVascEntryId();
|
||||
}
|
||||
if (state!=null) {
|
||||
entryName = state.getVascEntry().getId();
|
||||
}
|
||||
|
||||
VascEntry entry = vascController.getVascEntryController().getVascEntryById(entryName);
|
||||
if (entry==null) {
|
||||
throw new NullPointerException("Could not locate '"+entryName+"' from : "+vascController);
|
||||
}
|
||||
|
||||
frontendData.setVascFrontend(null); // reset data obj. todo rm this.
|
||||
frontendData.setVascController(vascController);
|
||||
entry.setVascFrontendData(frontendData);
|
||||
try {
|
||||
frontendData.initFrontendListeners(entry,"jsf");
|
||||
} catch (InstantiationException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
} catch (IllegalAccessException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
VascBackend backend = DefaultVascFactory.getProxyVascBackend(entry);
|
||||
frontendData.getVascEntryState().setVascBackend(backend);
|
||||
frontendData.getVascEntryState().setVascEntry(entry);
|
||||
|
||||
if (state!=null) {
|
||||
// copy prevois parent
|
||||
frontendData.getVascEntryState().setParent(state.getParent());
|
||||
}
|
||||
|
||||
if (link!=null) {
|
||||
// save state
|
||||
if (linkState==null) {
|
||||
frontendData.getVascEntryState().setParent(getVascEntry().getVascFrontendData().getVascEntryState());
|
||||
} else {
|
||||
frontendData.getVascEntryState().setParent(linkState);
|
||||
}
|
||||
|
||||
// Set parameters
|
||||
try {
|
||||
Object selected = getSupportBean().getSelected().getRecord();
|
||||
for (String parameterName:link.getEntryParameterFieldIdKeys()) {
|
||||
String fieldId = link.getEntryParameterFieldId(parameterName);
|
||||
VascEntryField v = getVascEntry().getVascEntryFieldById(fieldId);
|
||||
if (v==null) {
|
||||
logger.warning("Could nog get VascEntryField for fieldID: "+fieldId);
|
||||
continue;
|
||||
}
|
||||
if (v.getVascEntryFieldValue()==null) {
|
||||
logger.warning("Could not get VascEntryFieldValue for fieldID: "+fieldId);
|
||||
continue;
|
||||
}
|
||||
Object selectedValue = v.getVascEntryFieldValue().getValue(v, selected);
|
||||
|
||||
// set data parameter on new vasc entry
|
||||
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setDataParameter(parameterName, selectedValue);
|
||||
logger.fine("Setting link parameter: "+parameterName+" with: "+selectedValue);
|
||||
}
|
||||
|
||||
for (String fieldId:link.getEntryCreateFieldValueKeys()) {
|
||||
String selectedfieldId = link.getEntryParameterFieldId(fieldId);
|
||||
Object selectedValue = selected;
|
||||
if (selectedfieldId!=null) {
|
||||
VascEntryField v = getVascEntry().getVascEntryFieldById(selectedfieldId);
|
||||
selectedValue = v.getVascEntryFieldValue().getValue(v, selected);
|
||||
}
|
||||
|
||||
// create listener for new objects
|
||||
entry.getVascFrontendData().addVascEntryFrontendEventListener(new CreateEntryFieldValuesListener2(fieldId,selectedValue));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("error: "+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String entrySupportVar = (String)getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
|
||||
entry.getVascFrontendData().addVascEntryFrontendEventListener(new JSFVascEntryEventListener(entrySupportVar));
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
class CreateEntryFieldValuesListener2 implements VascEntryFrontendEventListener {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String fieldId = null;
|
||||
private Object value = null;
|
||||
public CreateEntryFieldValuesListener2(String fieldId,Object value) {
|
||||
if (fieldId==null) {
|
||||
throw new NullPointerException("fieldId may not be null");
|
||||
}
|
||||
this.fieldId=fieldId;
|
||||
this.value=value;
|
||||
}
|
||||
public VascFrontendEventType[] getEventTypes() {
|
||||
VascFrontendEventType[] result = {VascEntryFrontendEventListener.VascFrontendEventType.PRE_CREATE};
|
||||
return result;
|
||||
}
|
||||
public void vascEvent(VascEntry entry,Object data) {
|
||||
VascEntryField field = entry.getVascEntryFieldById(fieldId);
|
||||
try {
|
||||
field.getVascEntryFieldValue().setValue(field, data, value);
|
||||
} catch (VascException e) {
|
||||
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,572 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.web.jsf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.el.ELContext;
|
||||
import javax.el.MethodExpression;
|
||||
import javax.el.ValueExpression;
|
||||
import javax.faces.FacesException;
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.component.UIColumn;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIInput;
|
||||
import javax.faces.component.UIOutput;
|
||||
import javax.faces.component.UISelectMany;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.component.html.HtmlCommandLink;
|
||||
import javax.faces.component.html.HtmlInputText;
|
||||
import javax.faces.component.html.HtmlInputTextarea;
|
||||
import javax.faces.component.html.HtmlMessage;
|
||||
import javax.faces.component.html.HtmlOutputText;
|
||||
import javax.faces.component.html.HtmlSelectBooleanCheckbox;
|
||||
import javax.faces.component.html.HtmlSelectManyListbox;
|
||||
import javax.faces.component.html.HtmlSelectManyMenu;
|
||||
import javax.faces.component.html.HtmlSelectOneListbox;
|
||||
import javax.faces.component.html.HtmlSelectOneMenu;
|
||||
import javax.faces.component.html.HtmlSelectOneRadio;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.ResponseWriter;
|
||||
import javax.faces.event.AbortProcessingException;
|
||||
import javax.faces.event.ActionEvent;
|
||||
import javax.faces.event.MethodExpressionActionListener;
|
||||
import javax.faces.event.ValueChangeEvent;
|
||||
import javax.faces.event.ValueChangeListener;
|
||||
import javax.faces.render.Renderer;
|
||||
import javax.faces.validator.Validator;
|
||||
import javax.faces.validator.ValidatorException;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.VascLinkEntry;
|
||||
import net.forwardfire.vasc.core.VascLinkEntryType;
|
||||
import net.forwardfire.vasc.core.actions.RowVascAction;
|
||||
import net.forwardfire.vasc.core.ui.VascOptionValueModelListener;
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
import net.forwardfire.vasc.impl.actions.AddRowAction;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Renders an JSF vasc entry views.
|
||||
*
|
||||
* This is a bit hacky because I'm not a JSF guro.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 16, 2008
|
||||
*/
|
||||
public class JSFVascUIComponentRenderer extends Renderer {
|
||||
|
||||
private Logger logger = null;
|
||||
|
||||
public JSFVascUIComponentRenderer() {
|
||||
logger = Logger.getLogger(JSFVascUIComponentRenderer.class.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encodeBegin(FacesContext facesContext,UIComponent component) throws IOException {
|
||||
super.encodeBegin(facesContext, component);
|
||||
ResponseWriter writer = facesContext.getResponseWriter();
|
||||
JSFVascUIComponent comp = (JSFVascUIComponent)component;
|
||||
logger.fine("renderen encodeBegin for: "+comp.getRenderFacetState());
|
||||
writer.startElement("div", component);
|
||||
//String styleClass = (String)attributes.get(Shuffler.STYLECLASS_ATTRIBUTE_KEY);
|
||||
//writer.writeAttribute("class", styleClass, null);
|
||||
|
||||
// check if injection is needed
|
||||
if (comp.getInitClear()!=null) {
|
||||
injectAll(facesContext,comp,comp.getInitClear());
|
||||
|
||||
// hack for edit back action to set field disabled
|
||||
VascEntry entry = comp.getVascEntry();
|
||||
entry.getVascFrontendData().getVascFrontendHelper().editReadOnlyUIComponents(entry);
|
||||
}
|
||||
|
||||
// render the current facet of the vasc component
|
||||
UIComponent view = comp.getCurrentView();
|
||||
view.encodeAll(facesContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encodeEnd(FacesContext facesContext,UIComponent component) throws IOException {
|
||||
ResponseWriter writer = facesContext.getResponseWriter();
|
||||
writer.endElement("div");
|
||||
}
|
||||
|
||||
|
||||
// ========== All private
|
||||
|
||||
|
||||
private void injectAll(FacesContext context,JSFVascUIComponent comp,boolean clean) {
|
||||
|
||||
String injectEditFieldsId = (String)comp.getAttributes().get(JSFVascUIComponent.INJECT_EDIT_FIELDS_ID);
|
||||
String injectTableOptionsId = (String)comp.getAttributes().get(JSFVascUIComponent.INJECT_TABLE_OPTIONS_ID);
|
||||
String injectTableColumnsId = (String)comp.getAttributes().get(JSFVascUIComponent.INJECT_TABLE_COLUMNS_ID);
|
||||
|
||||
UIComponent injectEditFieldsComponent = JSFVascUIComponent.findComponentById(comp.getFacet("editView"),injectEditFieldsId);
|
||||
UIComponent injectTableOptionsComponent = JSFVascUIComponent.findComponentById(comp.getFacet("listView"),injectTableOptionsId);
|
||||
UIComponent injectTableColumnsComponent = JSFVascUIComponent.findComponentById(comp.getFacet("listView"),injectTableColumnsId);
|
||||
if (injectEditFieldsComponent==null) {
|
||||
throw new NullPointerException("Could not find injectEditFieldsId: "+injectEditFieldsId);
|
||||
}
|
||||
if (injectTableOptionsComponent==null) {
|
||||
throw new NullPointerException("Could not find injectTableOptionsId: "+injectTableOptionsId);
|
||||
}
|
||||
if (injectTableColumnsComponent==null) {
|
||||
throw new NullPointerException("Could not find injectTableColumnsId: "+injectTableColumnsId);
|
||||
}
|
||||
|
||||
if (clean) {
|
||||
logger.finer("Cleaning of all dynamic JSF components.");
|
||||
injectEditFieldsComponent.getChildren().clear();
|
||||
injectTableOptionsComponent.getChildren().clear();
|
||||
injectTableColumnsComponent.getChildren().clear();
|
||||
}
|
||||
logger.finer("Injection of all dynamic JSF components.");
|
||||
try {
|
||||
addEditFields(context, injectEditFieldsComponent);
|
||||
addTableOptions(context, injectTableOptionsComponent,comp);
|
||||
addColumns(context,comp,injectTableColumnsComponent );
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error while injecting; "+e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
|
||||
private String i18n(VascEntry entry,String key,Object...params) {
|
||||
return entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(key,params);
|
||||
}
|
||||
|
||||
|
||||
private void addEditFields(FacesContext fc,UIComponent grid) throws FacesException, VascException {
|
||||
|
||||
Application application = fc.getApplication();
|
||||
UIViewRoot viewRoot = fc.getViewRoot();
|
||||
|
||||
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(grid);
|
||||
VascEntry entry = comp.getVascEntry();
|
||||
if (entry==null) {
|
||||
throw new NullPointerException("No parent vasc component found.");
|
||||
}
|
||||
|
||||
String entrySupportVar = (String)comp.getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
|
||||
int column = 0;
|
||||
for (VascEntryField c:entry.getVascEntryFields()) {
|
||||
if (entry.getVascFrontendData().getVascFrontendHelper().renderEdit(c)==false) {
|
||||
continue;
|
||||
}
|
||||
//System.out.println("Multi edit size: "+c.getVascEntryFieldType().getUIComponentCount(c)+" of: "+c.getVascEntryFieldType());
|
||||
for (int i=0;i<c.getVascEntryFieldType().getUIComponentCount(c);i++) {
|
||||
|
||||
VascUIComponent label = c.getVascEntryFieldType().provideLabelUIComponent(i,c);
|
||||
VascValueModel model = new VascValueModel();
|
||||
model.setValue(i18n(entry,c.getName()));
|
||||
label.createComponent(entry,c,model,grid);
|
||||
|
||||
VascUIComponent editor = c.getVascEntryFieldType().provideEditorUIComponent(i,c);
|
||||
model = new VascValueModel(c.getVascEntryFieldType().provideEditorVascValueModel(i,c));
|
||||
//model.setValue(c.getVascEntryFieldValue().getValue(c, bean));
|
||||
//model.addListener(new VascColumnValueModelListener(c,bean));
|
||||
UIInput jsfEdit = (UIInput)editor.createComponent(entry,c,model,grid);
|
||||
jsfEdit.addValidator(new VascJSFInputValidator2(c.getId()));
|
||||
|
||||
int index = VascDataBackendBean.getIndexId(c);
|
||||
|
||||
ValueExpression ve7 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".selected.field"+index+"}", Object.class);
|
||||
jsfEdit.setValueExpression("value", ve7);
|
||||
|
||||
|
||||
ValueExpression ve8 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".selected != null}", Boolean.class);
|
||||
jsfEdit.setValueExpression("rendered", ve8);
|
||||
|
||||
HtmlMessage message = (HtmlMessage)application.createComponent(HtmlMessage.COMPONENT_TYPE);
|
||||
message.setId(viewRoot.createUniqueId());
|
||||
message.setFor(jsfEdit.getId());
|
||||
|
||||
message.setErrorClass("style_textBlue");
|
||||
message.setFatalClass("style_textRed");
|
||||
message.setInfoClass("style_textBlack");
|
||||
message.setWarnClass("style_textGreen");
|
||||
|
||||
grid.getChildren().add(message);
|
||||
|
||||
column++;
|
||||
|
||||
// i==0 is for multi field editor support... which is still very in progress
|
||||
if (i==0) {
|
||||
entry.getVascFrontendData().addFieldVascUIComponents(c, editor,jsfEdit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class VascJSFInputValidator2 implements Validator,Serializable {
|
||||
private static final long serialVersionUID = -5715250529474737642L;
|
||||
private Logger logger = null;
|
||||
private String fieldId = null;
|
||||
|
||||
public VascJSFInputValidator2(String fieldId) {
|
||||
this.fieldId=fieldId;
|
||||
logger = Logger.getLogger(VascJSFInputValidator2.class.getName());
|
||||
}
|
||||
public void validate(FacesContext context, UIComponent component,Object object) throws ValidatorException {
|
||||
// always oke, we are runned by phase listener
|
||||
}
|
||||
public void validatePhase(FacesContext context, UIComponent component,Object object) throws ValidatorException {
|
||||
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(component);
|
||||
VascEntry entry = comp.getVascEntry();
|
||||
StringBuffer buf;
|
||||
try {
|
||||
VascEntryField field = entry.getVascEntryFieldById(fieldId);
|
||||
|
||||
int index = VascDataBackendBean.getIndexId(field);
|
||||
String entrySupportVar = (String)comp.getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
|
||||
logger.fine("sup-sel: "+comp.getSupportBean().getSelected()+" index: "+index);
|
||||
|
||||
// note we have to set the value to the vasc backend before we can run validation
|
||||
ValueExpression ve7 = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".selected.field"+index+"}", Object.class);
|
||||
ve7.setValue(FacesContext.getCurrentInstance().getELContext(), object);
|
||||
|
||||
List<String> errors = entry.getVascFrontendData().getVascFrontendHelper().validateObjectField(field);
|
||||
logger.fine("Validate: "+component+" errors: "+errors.size()+" value: "+object);
|
||||
if (errors.isEmpty()) {
|
||||
return; // no errors
|
||||
}
|
||||
|
||||
buf = new StringBuffer(200);
|
||||
for (String err:errors) {
|
||||
buf.append(err);
|
||||
buf.append('\n');
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
FacesMessage message = new FacesMessage(buf.toString());
|
||||
message.setSeverity(FacesMessage.SEVERITY_ERROR);
|
||||
throw new ValidatorException(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void addTableOptions(FacesContext fc,UIComponent grid,JSFVascUIComponent comp) throws FacesException, VascException {
|
||||
|
||||
//Application application = fc.getApplication();
|
||||
//UIViewRoot viewRoot = fc.getViewRoot();
|
||||
|
||||
//JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(grid);
|
||||
VascEntry entry = comp.getVascEntry();
|
||||
|
||||
for (VascEntryField option:entry.getListOptions()) {
|
||||
for (int i=0;i<option.getVascEntryFieldType().getUIComponentCount(option);i++) {
|
||||
|
||||
VascUIComponent label = option.getVascEntryFieldType().provideLabelUIComponent(i,option);
|
||||
VascValueModel model = new VascValueModel();
|
||||
model.setValue(i18n(entry,option.getName()));
|
||||
label.createComponent(entry,option,model,grid);
|
||||
|
||||
VascUIComponent editor = option.getVascEntryFieldType().provideEditorUIComponent(i,option);
|
||||
model = new VascValueModel(option.getVascEntryFieldType().provideEditorVascValueModel(i,option));
|
||||
model.addListener(new VascOptionValueModelListener(option));
|
||||
model.setValue(option.getDefaultValue());
|
||||
UIInput jsfEdit = (UIInput)editor.createComponent(entry,option,model,grid);
|
||||
jsfEdit.addValueChangeListener(new ModelChangeListener(model));
|
||||
|
||||
if (comp.getInjectTableOptionOnChange()!=null && comp.getInjectTableOptionOnChange().isEmpty()==false) {
|
||||
if (jsfEdit instanceof HtmlSelectBooleanCheckbox) {
|
||||
((HtmlSelectBooleanCheckbox)jsfEdit).setOnchange(comp.getInjectTableOptionOnChange());
|
||||
}
|
||||
if (jsfEdit instanceof HtmlSelectManyMenu) {
|
||||
((HtmlSelectManyMenu)jsfEdit).setOnchange(comp.getInjectTableOptionOnChange());
|
||||
}
|
||||
if (jsfEdit instanceof HtmlInputText) {
|
||||
((HtmlInputText)jsfEdit).setOnchange(comp.getInjectTableOptionOnChange());
|
||||
}
|
||||
if (jsfEdit instanceof HtmlInputTextarea) {
|
||||
((HtmlInputTextarea)jsfEdit).setOnchange(comp.getInjectTableOptionOnChange());
|
||||
}
|
||||
if (jsfEdit instanceof HtmlSelectManyListbox) {
|
||||
((HtmlSelectManyListbox)jsfEdit).setOnchange(comp.getInjectTableOptionOnChange());
|
||||
}
|
||||
if (jsfEdit instanceof HtmlSelectOneMenu) {
|
||||
((HtmlSelectOneMenu)jsfEdit).setOnchange(comp.getInjectTableOptionOnChange());
|
||||
}
|
||||
if (jsfEdit instanceof HtmlSelectOneRadio) {
|
||||
((HtmlSelectOneRadio)jsfEdit).setOnchange(comp.getInjectTableOptionOnChange());
|
||||
}
|
||||
if (jsfEdit instanceof HtmlSelectOneListbox) {
|
||||
((HtmlSelectOneListbox)jsfEdit).setOnchange(comp.getInjectTableOptionOnChange());
|
||||
}
|
||||
}
|
||||
|
||||
Class<?> clazz = option.getVascEntryFieldType().getAutoDetectClass();
|
||||
if (clazz!=null && model.getValue()!=null) {
|
||||
if (clazz.equals(model.getValue().getClass())==false) {
|
||||
// lets try setting correct default.
|
||||
try {
|
||||
Constructor<?> c = clazz.getConstructor(String.class);
|
||||
Object value = c.newInstance(model.getValue());
|
||||
jsfEdit.setValue(value);
|
||||
} catch (Exception e) {
|
||||
throw new VascException(e);
|
||||
}
|
||||
} else {
|
||||
jsfEdit.setValue(model.getValue()); // set default value
|
||||
}
|
||||
}
|
||||
// i==0 is for multi field editor support... which is stell very in progress aka not working
|
||||
if (i==0) {
|
||||
entry.getVascFrontendData().addFieldVascUIComponents(option, editor,jsfEdit);
|
||||
}
|
||||
}
|
||||
}
|
||||
entry.getVascFrontendData().getVascFrontendHelper().headerOptionsCreatedFillData(entry);
|
||||
}
|
||||
public class ModelChangeListener implements ValueChangeListener,Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
VascValueModel model;
|
||||
public ModelChangeListener(VascValueModel model) {
|
||||
this.model=model;
|
||||
}
|
||||
public void processValueChange(ValueChangeEvent event) throws AbortProcessingException {
|
||||
try {
|
||||
model.setValue(event.getNewValue());
|
||||
} catch (VascException e) {
|
||||
throw new AbortProcessingException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addColumns(FacesContext fc,JSFVascUIComponent comp,UIComponent table) {
|
||||
|
||||
Application application = fc.getApplication();
|
||||
UIViewRoot viewRoot = fc.getViewRoot();
|
||||
|
||||
VascEntry entry = comp.getVascEntry();
|
||||
String entrySupportVar = (String)comp.getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
|
||||
String tableRecordVar = (String)comp.getAttributes().get(JSFVascUIComponent.TABLE_RECORD_VAR_KEY);
|
||||
|
||||
if (!entry.getVascFrontendData().getVascFrontendHelper().getMultiRowActions(entry).isEmpty()) {
|
||||
UIColumn colUp = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE);
|
||||
colUp.setId(viewRoot.createUniqueId());
|
||||
|
||||
/*
|
||||
// Select box head in table
|
||||
HtmlCommandLink selectAll = (HtmlCommandLink)application.createComponent(HtmlCommandLink.COMPONENT_TYPE);
|
||||
selectAll.setId(viewRoot.createUniqueId());
|
||||
selectAll.setType("selectAll");
|
||||
MethodExpression actionExpression = getMethodExpression("#{"+entrySupportVar+".selectAllAction}");
|
||||
MethodExpressionActionListener meActionListener = new MethodExpressionActionListener(actionExpression);
|
||||
selectAll.addActionListener(meActionListener);
|
||||
|
||||
HtmlOutputText orderUp = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
|
||||
orderUp.setId(viewRoot.createUniqueId());
|
||||
orderUp.setEscape(false);
|
||||
orderUp.setValue("selectAll");
|
||||
|
||||
selectAll.getChildren().add(orderUp);
|
||||
colUp.setHeader(selectAll);
|
||||
*/
|
||||
|
||||
HtmlSelectBooleanCheckbox select = (HtmlSelectBooleanCheckbox)application.createComponent(HtmlSelectBooleanCheckbox.COMPONENT_TYPE);
|
||||
select.setId(viewRoot.createUniqueId());
|
||||
select.setStyleClass("js_table_select_all");
|
||||
ValueExpression ve1 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(),"#{"+entrySupportVar+".vascEntry.vascFrontendData.vascEntryState.multiActionSelection["+tableRecordVar+".recordId]}",Object.class);
|
||||
select.setValueExpression("value", ve1);
|
||||
|
||||
colUp.getChildren().add(select);
|
||||
table.getChildren().add(colUp);
|
||||
}
|
||||
|
||||
|
||||
for (VascEntryField c:entry.getVascEntryFields()) {
|
||||
if (entry.getVascFrontendData().getVascFrontendHelper().renderList(c)==false) {
|
||||
continue;
|
||||
}
|
||||
UIColumn col = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE);
|
||||
col.setId(viewRoot.createUniqueId());
|
||||
|
||||
HtmlCommandLink link = (HtmlCommandLink)application.createComponent(HtmlCommandLink.COMPONENT_TYPE);
|
||||
link.setId(viewRoot.createUniqueId());
|
||||
link.setType(c.getId());
|
||||
|
||||
MethodExpression actionExpression = getMethodExpression("#{"+entrySupportVar+".sortAction}");
|
||||
MethodExpressionActionListener meActionListener = new MethodExpressionActionListener(actionExpression);
|
||||
link.addActionListener(meActionListener);
|
||||
|
||||
HtmlOutputText out2 = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
|
||||
out2.setId(viewRoot.createUniqueId());
|
||||
out2.setEscape(false);
|
||||
out2.setValue(i18n(entry,c.getName())+" ");
|
||||
|
||||
HtmlOutputText orderUp = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
|
||||
orderUp.setId(viewRoot.createUniqueId());
|
||||
orderUp.setEscape(false);
|
||||
orderUp.setValue("↑"); // ↑
|
||||
ValueExpression ren2 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".sortOrder==true and "+entrySupportVar+".sortField=='"+c.getId()+"'}", Boolean.class);
|
||||
orderUp.setValueExpression("rendered", ren2);
|
||||
|
||||
HtmlOutputText orderDown = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
|
||||
orderDown.setId(viewRoot.createUniqueId());
|
||||
orderDown.setEscape(false);
|
||||
orderDown.setValue("↓"); // ↓
|
||||
ValueExpression ren3 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".sortOrder==false and "+entrySupportVar+".sortField=='"+c.getId()+"'}", Boolean.class);
|
||||
orderDown.setValueExpression("rendered", ren3);
|
||||
|
||||
link.getChildren().add(out2);
|
||||
link.getChildren().add(orderUp);
|
||||
link.getChildren().add(orderDown);
|
||||
col.setHeader(link);
|
||||
|
||||
HtmlOutputText out = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
|
||||
out.setId(viewRoot.createUniqueId());
|
||||
int index = VascDataBackendBean.getIndexId(c);
|
||||
ValueExpression ve1 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(),"#{"+tableRecordVar+".field"+index+"}",Object.class);
|
||||
out.setValueExpression("value", ve1);
|
||||
|
||||
col.getChildren().add(out);
|
||||
table.getChildren().add(col);
|
||||
}
|
||||
|
||||
if (entry.getVascFrontendData().getVascEntryState().getVascBackend().isRecordMoveable()) {
|
||||
UIColumn colUp = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE);
|
||||
colUp.setId(viewRoot.createUniqueId());
|
||||
|
||||
HtmlCommandLink linkUp = (HtmlCommandLink)application.createComponent(HtmlCommandLink.COMPONENT_TYPE);
|
||||
linkUp.setId(viewRoot.createUniqueId());
|
||||
linkUp.setType("up");
|
||||
MethodExpression actionExpression = getMethodExpression("#{"+entrySupportVar+".moveAction}");
|
||||
MethodExpressionActionListener meActionListener = new MethodExpressionActionListener(actionExpression);
|
||||
linkUp.addActionListener(meActionListener);
|
||||
|
||||
HtmlOutputText orderUp = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
|
||||
orderUp.setId(viewRoot.createUniqueId());
|
||||
orderUp.setEscape(false);
|
||||
orderUp.setValue("↑ up"); // ↑
|
||||
|
||||
linkUp.getChildren().add(orderUp);
|
||||
colUp.getChildren().add(linkUp);
|
||||
table.getChildren().add(colUp);
|
||||
|
||||
HtmlCommandLink linkDown = (HtmlCommandLink)application.createComponent(HtmlCommandLink.COMPONENT_TYPE);
|
||||
linkDown.setId(viewRoot.createUniqueId());
|
||||
linkDown.setType("down");
|
||||
MethodExpression actionExpression2 = getMethodExpression("#{"+entrySupportVar+".moveAction}");
|
||||
MethodExpressionActionListener meActionListener2 = new MethodExpressionActionListener(actionExpression2);
|
||||
linkDown.addActionListener(meActionListener2);
|
||||
|
||||
UIColumn colDown = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE);
|
||||
colDown.setId(viewRoot.createUniqueId());
|
||||
HtmlOutputText orderDown = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
|
||||
orderDown.setId(viewRoot.createUniqueId());
|
||||
orderDown.setEscape(false);
|
||||
orderDown.setValue("↓ down"); // ↓
|
||||
|
||||
linkDown.getChildren().add(orderDown);
|
||||
colDown.getChildren().add(linkDown);
|
||||
table.getChildren().add(colDown);
|
||||
}
|
||||
|
||||
for (VascLinkEntry vascLink:entry.getVascFrontendData().getVascFrontendHelper().getVascLinkEntryByType(entry, VascLinkEntryType.LIST)) {
|
||||
UIColumn col = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE);
|
||||
col.setId(viewRoot.createUniqueId());
|
||||
|
||||
UIOutput colHeader = (UIOutput)application.createComponent(UIOutput.COMPONENT_TYPE);
|
||||
colHeader.setId(viewRoot.createUniqueId());
|
||||
colHeader.setValue("link");
|
||||
col.setHeader(colHeader);
|
||||
|
||||
HtmlCommandLink link = (HtmlCommandLink)application.createComponent(HtmlCommandLink.COMPONENT_TYPE);
|
||||
link.setId(viewRoot.createUniqueId());
|
||||
link.setType(vascLink.getId());
|
||||
MethodExpression actionExpression = getMethodExpression("#{"+entrySupportVar+".linkAction}");
|
||||
MethodExpressionActionListener meActionListener = new MethodExpressionActionListener(actionExpression);
|
||||
link.addActionListener(meActionListener);
|
||||
|
||||
HtmlOutputText out = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
|
||||
out.setId(viewRoot.createUniqueId());
|
||||
out.setValue(i18n(entry,vascLink.getName()));
|
||||
|
||||
link.getChildren().add(out);
|
||||
col.getChildren().add(link);
|
||||
|
||||
table.getChildren().add(col);
|
||||
}
|
||||
|
||||
for (RowVascAction action:entry.getRowActions()) {
|
||||
if (entry.getVascFrontendData().getVascFrontendHelper().renderRowVascAction(action)==false) {
|
||||
continue;
|
||||
}
|
||||
if (AddRowAction.ACTION_ID.equals(action.getId())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
UIColumn col = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE);
|
||||
col.setId(viewRoot.createUniqueId());
|
||||
|
||||
UIOutput colHeader = (UIOutput)application.createComponent(UIOutput.COMPONENT_TYPE);
|
||||
colHeader.setId(viewRoot.createUniqueId());
|
||||
colHeader.setValue(i18n(entry,action.getName()));
|
||||
col.setHeader(colHeader);
|
||||
|
||||
HtmlCommandLink link = (HtmlCommandLink)application.createComponent(HtmlCommandLink.COMPONENT_TYPE);
|
||||
link.setId(viewRoot.createUniqueId());
|
||||
link.setType(action.getId());
|
||||
MethodExpression actionExpression = getMethodExpression("#{"+entrySupportVar+".rowAction}");
|
||||
MethodExpressionActionListener meActionListener = new MethodExpressionActionListener(actionExpression);
|
||||
link.addActionListener(meActionListener);
|
||||
|
||||
HtmlOutputText out = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
|
||||
out.setId(viewRoot.createUniqueId());
|
||||
out.setValue(i18n(entry,action.getName()));
|
||||
|
||||
link.getChildren().add(out);
|
||||
col.getChildren().add(link);
|
||||
|
||||
table.getChildren().add(col);
|
||||
}
|
||||
}
|
||||
|
||||
private MethodExpression getMethodExpression(String name) {
|
||||
Class<?>[] argtypes = new Class[1];
|
||||
argtypes[0] = ActionEvent.class;
|
||||
FacesContext facesCtx = FacesContext.getCurrentInstance();
|
||||
ELContext elContext = facesCtx.getELContext();
|
||||
return facesCtx.getApplication().getExpressionFactory().createMethodExpression(elContext, name, null, argtypes);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,232 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.web.jsf;
|
||||
|
||||
|
||||
import javax.el.ValueExpression;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.webapp.UIComponentELTag;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 16, 2008
|
||||
*/
|
||||
public class JSFVascUIComponentTag extends UIComponentELTag {
|
||||
|
||||
public static final String COMPONENT_TYPE = "vasc.jsf.component";
|
||||
public static final String RENDERER_TYPE = "vasc.jsf.component.renderer";
|
||||
|
||||
private ValueExpression vascController = null;
|
||||
private ValueExpression vascFrontendData = null;
|
||||
private ValueExpression entryName = null;
|
||||
private ValueExpression entrySupportVar = null;
|
||||
private ValueExpression tableRecordVar = null;
|
||||
private ValueExpression injectEditFieldsId = null;
|
||||
private ValueExpression injectTableOptionsId = null;
|
||||
private ValueExpression injectTableColumnsId = null;
|
||||
private ValueExpression disableLinkColumns = null;
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return COMPONENT_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRendererType() {
|
||||
return RENDERER_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.webapp.UIComponentELTag#setProperties(javax.faces.component.UIComponent)
|
||||
*/
|
||||
@Override
|
||||
protected void setProperties(UIComponent component) {
|
||||
super.setProperties(component);
|
||||
processProperty(component, vascController, JSFVascUIComponent.VASC_CONTROLLER_KEY);
|
||||
processProperty(component, vascFrontendData, JSFVascUIComponent.VASC_FRONTEND_DATA_KEY);
|
||||
processProperty(component, entryName, JSFVascUIComponent.ENTRY_NAME_KEY);
|
||||
processProperty(component, entrySupportVar, JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
|
||||
processProperty(component, tableRecordVar, JSFVascUIComponent.TABLE_RECORD_VAR_KEY);
|
||||
processProperty(component, injectEditFieldsId, JSFVascUIComponent.INJECT_EDIT_FIELDS_ID);
|
||||
processProperty(component, injectTableOptionsId,JSFVascUIComponent.INJECT_TABLE_OPTIONS_ID);
|
||||
processProperty(component, injectTableColumnsId,JSFVascUIComponent.INJECT_TABLE_COLUMNS_ID);
|
||||
processProperty(component, disableLinkColumns ,JSFVascUIComponent.DISABLE_LINK_COLUMNS);
|
||||
}
|
||||
|
||||
public void release() {
|
||||
super.release();
|
||||
vascController = null;
|
||||
vascFrontendData = null;
|
||||
entryName = null;
|
||||
entrySupportVar = null;
|
||||
tableRecordVar = null;
|
||||
injectEditFieldsId = null;
|
||||
injectTableOptionsId = null;
|
||||
injectTableColumnsId = null;
|
||||
disableLinkColumns = null;
|
||||
}
|
||||
|
||||
protected final void processProperty(final UIComponent component, final ValueExpression property,final String propertyName) {
|
||||
if (property != null) {
|
||||
if(property.isLiteralText()) {
|
||||
component.getAttributes().put(propertyName, property.getExpressionString());
|
||||
} else {
|
||||
component.setValueExpression(propertyName, property);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============= BEAN FIELDS
|
||||
|
||||
/**
|
||||
* @return the vascController
|
||||
*/
|
||||
public ValueExpression getVascController() {
|
||||
return vascController;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascController the vascController to set
|
||||
*/
|
||||
public void setVascController(ValueExpression vascController) {
|
||||
this.vascController = vascController;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the entryName
|
||||
*/
|
||||
public ValueExpression getEntryName() {
|
||||
return entryName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entryName the entryName to set
|
||||
*/
|
||||
public void setEntryName(ValueExpression entryName) {
|
||||
this.entryName = entryName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the vascFrontendData
|
||||
*/
|
||||
public ValueExpression getVascFrontendData() {
|
||||
return vascFrontendData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vascFrontendData the vascFrontendData to set
|
||||
*/
|
||||
public void setVascFrontendData(ValueExpression vascFrontendData) {
|
||||
this.vascFrontendData = vascFrontendData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the entrySupportVar
|
||||
*/
|
||||
public ValueExpression getEntrySupportVar() {
|
||||
return entrySupportVar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entrySupportVar the entrySupportVar to set
|
||||
*/
|
||||
public void setEntrySupportVar(ValueExpression entrySupportVar) {
|
||||
this.entrySupportVar = entrySupportVar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the injectEditFieldsId
|
||||
*/
|
||||
public ValueExpression getInjectEditFieldsId() {
|
||||
return injectEditFieldsId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param injectEditFieldsId the injectEditFieldsId to set
|
||||
*/
|
||||
public void setInjectEditFieldsId(ValueExpression injectEditFieldsId) {
|
||||
this.injectEditFieldsId = injectEditFieldsId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the injectTableOptionsId
|
||||
*/
|
||||
public ValueExpression getInjectTableOptionsId() {
|
||||
return injectTableOptionsId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param injectTableOptionsId the injectTableOptionsId to set
|
||||
*/
|
||||
public void setInjectTableOptionsId(ValueExpression injectTableOptionsId) {
|
||||
this.injectTableOptionsId = injectTableOptionsId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the injectTableColumnsId
|
||||
*/
|
||||
public ValueExpression getInjectTableColumnsId() {
|
||||
return injectTableColumnsId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param injectTableColumnsId the injectTableColumnsId to set
|
||||
*/
|
||||
public void setInjectTableColumnsId(ValueExpression injectTableColumnsId) {
|
||||
this.injectTableColumnsId = injectTableColumnsId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tableRecordVar
|
||||
*/
|
||||
public ValueExpression getTableRecordVar() {
|
||||
return tableRecordVar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tableRecordVar the tableRecordVar to set
|
||||
*/
|
||||
public void setTableRecordVar(ValueExpression tableRecordVar) {
|
||||
this.tableRecordVar = tableRecordVar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the disableLinkColumns
|
||||
*/
|
||||
public ValueExpression getDisableLinkColumns() {
|
||||
return disableLinkColumns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param disableLinkColumns the disableLinkColumns to set
|
||||
*/
|
||||
public void setDisableLinkColumns(ValueExpression disableLinkColumns) {
|
||||
this.disableLinkColumns = disableLinkColumns;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package net.forwardfire.vasc.frontends.web.jsf;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIInput;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.PhaseEvent;
|
||||
import javax.faces.event.PhaseId;
|
||||
import javax.faces.event.PhaseListener;
|
||||
import javax.faces.validator.Validator;
|
||||
import javax.faces.validator.ValidatorException;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.frontends.web.jsf.JSFVascUIComponentRenderer.VascJSFInputValidator2;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* JSFVascValidatePhaseListener runs the vasc field edit fields.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Nov 15, 2009
|
||||
*/
|
||||
public class JSFVascValidatePhaseListener implements PhaseListener {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Logger logger = null;
|
||||
|
||||
public JSFVascValidatePhaseListener() {
|
||||
logger = Logger.getLogger(JSFVascValidatePhaseListener.class.getName());
|
||||
}
|
||||
|
||||
private static final String SAVE_ACTION_ID_HACK = "VASC_SAVE";
|
||||
|
||||
public void afterPhase(PhaseEvent event) {
|
||||
FacesContext context = event.getFacesContext();
|
||||
|
||||
// we really only want validation this early when saveing.
|
||||
// this is currently a bit hacky impl;
|
||||
Map<String,String> requestMap = context.getExternalContext().getRequestParameterMap();
|
||||
for (String key:requestMap.keySet()) {
|
||||
if (key.contains(SAVE_ACTION_ID_HACK)) {
|
||||
validateUIInput(context.getViewRoot(),context);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void beforePhase(PhaseEvent event) {
|
||||
}
|
||||
public PhaseId getPhaseId() {
|
||||
return PhaseId.PROCESS_VALIDATIONS;
|
||||
}
|
||||
private void validateUIInput(UIComponent component,FacesContext context) {
|
||||
if (component instanceof UIInput) {
|
||||
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(component);
|
||||
logger.finer("Validate UIInput: "+component+" comp: "+comp);
|
||||
if (comp==null) {
|
||||
return; // non-vasc ui-input
|
||||
}
|
||||
if (comp.getSupportBean().getSelected()==null) {
|
||||
return; // no editing
|
||||
}
|
||||
VascEntry entry = comp.getVascEntry();
|
||||
if (entry.getVascFrontendData().getVascEntryState().getEntryDataObject()==null) {
|
||||
return; // we are not in edit mode.
|
||||
}
|
||||
UIInput in = (UIInput)component;
|
||||
for (Validator v:in.getValidators()) {
|
||||
if (v instanceof VascJSFInputValidator2) {
|
||||
VascJSFInputValidator2 validator = (VascJSFInputValidator2)v;
|
||||
try {
|
||||
in.setValid(true);
|
||||
validator.validatePhase(context, in, in.getValue());
|
||||
} catch (ValidatorException ve) {
|
||||
in.setValid(false);
|
||||
|
||||
// note: ve has the message already but this is the UIInput way
|
||||
FacesMessage message;
|
||||
String validatorMessageString = in.getValidatorMessage();
|
||||
if (null != validatorMessageString) {
|
||||
message = new FacesMessage(FacesMessage.SEVERITY_ERROR,validatorMessageString,validatorMessageString);
|
||||
message.setSeverity(FacesMessage.SEVERITY_ERROR);
|
||||
} else {
|
||||
message = ve.getFacesMessage();
|
||||
}
|
||||
if (message != null) {
|
||||
context.addMessage(in.getClientId(context), message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Iterator<UIComponent> kids = component.getFacetsAndChildren();
|
||||
while (kids.hasNext()) {
|
||||
UIComponent child = kids.next();
|
||||
validateUIInput(child,context);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,521 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.web.jsf;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.entry.VascEntryFieldValue;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 03, 2009
|
||||
*/
|
||||
public class VascDataBackendBean implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 3881688974089760074L;
|
||||
private VascEntry entry = null;
|
||||
private Object record = null;
|
||||
private boolean realValue = false;
|
||||
private int recordId = 0;
|
||||
|
||||
public VascDataBackendBean(VascEntry entry,Object record,int recordId) {
|
||||
this.entry=entry;
|
||||
this.record=record;
|
||||
this.recordId=recordId;
|
||||
}
|
||||
|
||||
public boolean isRealValue() {
|
||||
return realValue;
|
||||
}
|
||||
public void setRealValue(boolean realValue) {
|
||||
this.realValue=realValue;
|
||||
}
|
||||
|
||||
static public VascEntryField getFieldIdByIndex(VascEntry entry,int index) {
|
||||
if (index>entry.getVascEntryFields().size()) {
|
||||
throw new IllegalArgumentException("Index is bigger then total field size: "+index);
|
||||
}
|
||||
return entry.getVascEntryFields().get(index);
|
||||
}
|
||||
|
||||
static public int getIndexId(VascEntryField field) {
|
||||
int i =0;
|
||||
for (VascEntryField f:field.getVascEntry().getVascEntryFields()) {
|
||||
if (f.getId().equals(field.getId())) {
|
||||
return i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
throw new IllegalArgumentException("Could not find field.");
|
||||
}
|
||||
|
||||
private Object getValue(int index) {
|
||||
try {
|
||||
VascEntryField field = getFieldIdByIndex(entry,index);
|
||||
VascEntryFieldValue value = field.getVascEntryFieldValue();
|
||||
if (isRealValue()) {
|
||||
return value.getValue(field, record);
|
||||
}
|
||||
return value.getDisplayValue(field, record);
|
||||
} catch (VascException e) {
|
||||
return "Error: "+e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
private void setValue(int index,Object valueObject) {
|
||||
try {
|
||||
VascEntryField field = getFieldIdByIndex(entry,index);
|
||||
VascEntryFieldValue value = field.getVascEntryFieldValue();
|
||||
value.setValue(field, record,valueObject);
|
||||
} catch (VascException e) {
|
||||
throw new RuntimeException("Could not set value on record.",e);
|
||||
}
|
||||
}
|
||||
|
||||
public Object getRecord() {
|
||||
return record;
|
||||
}
|
||||
|
||||
public int getRecordId() {
|
||||
return recordId;
|
||||
}
|
||||
|
||||
// GET/SET bean methods for using in EL
|
||||
|
||||
|
||||
public Object getField0() {
|
||||
return getValue(0);
|
||||
}
|
||||
|
||||
public void setField0(Object o) {
|
||||
setValue(0,o);
|
||||
}
|
||||
|
||||
public Object getField1() {
|
||||
return getValue(1);
|
||||
}
|
||||
|
||||
public void setField1(Object o) {
|
||||
setValue(1,o);
|
||||
}
|
||||
|
||||
public Object getField2() {
|
||||
return getValue(2);
|
||||
}
|
||||
|
||||
public void setField2(Object o) {
|
||||
setValue(2,o);
|
||||
}
|
||||
|
||||
public Object getField3() {
|
||||
return getValue(3);
|
||||
}
|
||||
|
||||
public void setField3(Object o) {
|
||||
setValue(3,o);
|
||||
}
|
||||
|
||||
public Object getField4() {
|
||||
return getValue(4);
|
||||
}
|
||||
|
||||
public void setField4(Object o) {
|
||||
setValue(4,o);
|
||||
}
|
||||
|
||||
public Object getField5() {
|
||||
return getValue(5);
|
||||
}
|
||||
|
||||
public void setField5(Object o) {
|
||||
setValue(5,o);
|
||||
}
|
||||
|
||||
public Object getField6() {
|
||||
return getValue(6);
|
||||
}
|
||||
|
||||
public void setField6(Object o) {
|
||||
setValue(6,o);
|
||||
}
|
||||
|
||||
public Object getField7() {
|
||||
return getValue(7);
|
||||
}
|
||||
|
||||
public void setField7(Object o) {
|
||||
setValue(7,o);
|
||||
}
|
||||
|
||||
public Object getField8() {
|
||||
return getValue(8);
|
||||
}
|
||||
|
||||
public void setField8(Object o) {
|
||||
setValue(8,o);
|
||||
}
|
||||
|
||||
public Object getField9() {
|
||||
return getValue(9);
|
||||
}
|
||||
|
||||
public void setField9(Object o) {
|
||||
setValue(9,o);
|
||||
}
|
||||
|
||||
|
||||
public Object getField10() {
|
||||
return getValue(10);
|
||||
}
|
||||
|
||||
public void setField10(Object o) {
|
||||
setValue(10,o);
|
||||
}
|
||||
|
||||
public Object getField11() {
|
||||
return getValue(11);
|
||||
}
|
||||
|
||||
public void setField11(Object o) {
|
||||
setValue(11,o);
|
||||
}
|
||||
|
||||
public Object getField12() {
|
||||
return getValue(12);
|
||||
}
|
||||
|
||||
public void setField12(Object o) {
|
||||
setValue(12,o);
|
||||
}
|
||||
|
||||
public Object getField13() {
|
||||
return getValue(13);
|
||||
}
|
||||
|
||||
public void setField13(Object o) {
|
||||
setValue(13,o);
|
||||
}
|
||||
|
||||
public Object getField14() {
|
||||
return getValue(14);
|
||||
}
|
||||
|
||||
public void setField14(Object o) {
|
||||
setValue(14,o);
|
||||
}
|
||||
|
||||
public Object getField15() {
|
||||
return getValue(15);
|
||||
}
|
||||
|
||||
public void setField15(Object o) {
|
||||
setValue(15,o);
|
||||
}
|
||||
|
||||
public Object getField16() {
|
||||
return getValue(16);
|
||||
}
|
||||
|
||||
public void setField16(Object o) {
|
||||
setValue(16,o);
|
||||
}
|
||||
|
||||
public Object getField17() {
|
||||
return getValue(17);
|
||||
}
|
||||
|
||||
public void setField17(Object o) {
|
||||
setValue(17,o);
|
||||
}
|
||||
|
||||
public Object getField18() {
|
||||
return getValue(18);
|
||||
}
|
||||
|
||||
public void setField18(Object o) {
|
||||
setValue(18,o);
|
||||
}
|
||||
|
||||
public Object getField19() {
|
||||
return getValue(19);
|
||||
}
|
||||
|
||||
public void setField19(Object o) {
|
||||
setValue(19,o);
|
||||
}
|
||||
|
||||
|
||||
public Object getField20() {
|
||||
return getValue(20);
|
||||
}
|
||||
|
||||
public void setField20(Object o) {
|
||||
setValue(20,o);
|
||||
}
|
||||
|
||||
public Object getField21() {
|
||||
return getValue(21);
|
||||
}
|
||||
|
||||
public void setField21(Object o) {
|
||||
setValue(21,o);
|
||||
}
|
||||
|
||||
public Object getField22() {
|
||||
return getValue(22);
|
||||
}
|
||||
|
||||
public void setField22(Object o) {
|
||||
setValue(22,o);
|
||||
}
|
||||
|
||||
public Object getField23() {
|
||||
return getValue(23);
|
||||
}
|
||||
|
||||
public void setField23(Object o) {
|
||||
setValue(23,o);
|
||||
}
|
||||
|
||||
public Object getField24() {
|
||||
return getValue(24);
|
||||
}
|
||||
|
||||
public void setField24(Object o) {
|
||||
setValue(24,o);
|
||||
}
|
||||
|
||||
public Object getField25() {
|
||||
return getValue(25);
|
||||
}
|
||||
|
||||
public void setField25(Object o) {
|
||||
setValue(25,o);
|
||||
}
|
||||
|
||||
public Object getField26() {
|
||||
return getValue(26);
|
||||
}
|
||||
|
||||
public void setField26(Object o) {
|
||||
setValue(26,o);
|
||||
}
|
||||
|
||||
public Object getField27() {
|
||||
return getValue(27);
|
||||
}
|
||||
|
||||
public void setField27(Object o) {
|
||||
setValue(27,o);
|
||||
}
|
||||
|
||||
public Object getField28() {
|
||||
return getValue(28);
|
||||
}
|
||||
|
||||
public void setField28(Object o) {
|
||||
setValue(28,o);
|
||||
}
|
||||
|
||||
public Object getField29() {
|
||||
return getValue(29);
|
||||
}
|
||||
|
||||
public void setField29(Object o) {
|
||||
setValue(29,o);
|
||||
}
|
||||
|
||||
|
||||
public Object getField30() {
|
||||
return getValue(30);
|
||||
}
|
||||
|
||||
public void setField30(Object o) {
|
||||
setValue(30,o);
|
||||
}
|
||||
|
||||
public Object getField31() {
|
||||
return getValue(31);
|
||||
}
|
||||
|
||||
public void setField31(Object o) {
|
||||
setValue(31,o);
|
||||
}
|
||||
|
||||
public Object getField32() {
|
||||
return getValue(32);
|
||||
}
|
||||
|
||||
public void setField32(Object o) {
|
||||
setValue(32,o);
|
||||
}
|
||||
|
||||
public Object getField33() {
|
||||
return getValue(33);
|
||||
}
|
||||
|
||||
public void setField33(Object o) {
|
||||
setValue(33,o);
|
||||
}
|
||||
|
||||
public Object getField34() {
|
||||
return getValue(34);
|
||||
}
|
||||
|
||||
public void setField34(Object o) {
|
||||
setValue(34,o);
|
||||
}
|
||||
|
||||
public Object getField35() {
|
||||
return getValue(35);
|
||||
}
|
||||
|
||||
public void setField35(Object o) {
|
||||
setValue(35,o);
|
||||
}
|
||||
|
||||
public Object getField36() {
|
||||
return getValue(36);
|
||||
}
|
||||
|
||||
public void setField36(Object o) {
|
||||
setValue(36,o);
|
||||
}
|
||||
|
||||
public Object getField37() {
|
||||
return getValue(37);
|
||||
}
|
||||
|
||||
public void setField37(Object o) {
|
||||
setValue(37,o);
|
||||
}
|
||||
|
||||
public Object getField38() {
|
||||
return getValue(38);
|
||||
}
|
||||
|
||||
public void setField38(Object o) {
|
||||
setValue(38,o);
|
||||
}
|
||||
|
||||
public Object getField39() {
|
||||
return getValue(39);
|
||||
}
|
||||
|
||||
public void setField39(Object o) {
|
||||
setValue(39,o);
|
||||
}
|
||||
|
||||
|
||||
public Object getField40() {
|
||||
return getValue(40);
|
||||
}
|
||||
|
||||
public void setField40(Object o) {
|
||||
setValue(40,o);
|
||||
}
|
||||
|
||||
public Object getField41() {
|
||||
return getValue(41);
|
||||
}
|
||||
|
||||
public void setField41(Object o) {
|
||||
setValue(41,o);
|
||||
}
|
||||
|
||||
public Object getField42() {
|
||||
return getValue(42);
|
||||
}
|
||||
|
||||
public void setField42(Object o) {
|
||||
setValue(42,o);
|
||||
}
|
||||
|
||||
public Object getField43() {
|
||||
return getValue(43);
|
||||
}
|
||||
|
||||
public void setField43(Object o) {
|
||||
setValue(43,o);
|
||||
}
|
||||
|
||||
public Object getField44() {
|
||||
return getValue(44);
|
||||
}
|
||||
|
||||
public void setField44(Object o) {
|
||||
setValue(44,o);
|
||||
}
|
||||
|
||||
public Object getField45() {
|
||||
return getValue(45);
|
||||
}
|
||||
|
||||
public void setField45(Object o) {
|
||||
setValue(45,o);
|
||||
}
|
||||
|
||||
public Object getField46() {
|
||||
return getValue(46);
|
||||
}
|
||||
|
||||
public void setField46(Object o) {
|
||||
setValue(46,o);
|
||||
}
|
||||
|
||||
public Object getField47() {
|
||||
return getValue(47);
|
||||
}
|
||||
|
||||
public void setField47(Object o) {
|
||||
setValue(47,o);
|
||||
}
|
||||
|
||||
public Object getField48() {
|
||||
return getValue(48);
|
||||
}
|
||||
|
||||
public void setField48(Object o) {
|
||||
setValue(48,o);
|
||||
}
|
||||
|
||||
public Object getField49() {
|
||||
return getValue(49);
|
||||
}
|
||||
|
||||
public void setField49(Object o) {
|
||||
setValue(49,o);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,191 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.web.jsf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.faces.FactoryFinder;
|
||||
import javax.faces.application.ViewExpiredException;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.FacesContextFactory;
|
||||
import javax.faces.lifecycle.Lifecycle;
|
||||
import javax.faces.lifecycle.LifecycleFactory;
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* Parses the Request info path info 3 vasc attributes an dispatches the request to the templateFile.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 21, 2009
|
||||
*/
|
||||
public class VascRequestFacesFilter implements Filter {
|
||||
|
||||
private static final long serialVersionUID = 10l;
|
||||
private Logger logger = null;
|
||||
private String templateFile = null;
|
||||
private ServletContext servletContext = null;
|
||||
private String resourceBundle = null;
|
||||
|
||||
/**
|
||||
* @see javax.servlet.Filter#destroy()
|
||||
*/
|
||||
public void destroy() {
|
||||
servletContext = null;
|
||||
templateFile = null;
|
||||
logger = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
|
||||
*/
|
||||
public void init(FilterConfig config) throws ServletException {
|
||||
logger = Logger.getLogger(VascRequestFacesFilter.class.getName());
|
||||
templateFile=config.getInitParameter("templateFile");
|
||||
if (templateFile==null) {
|
||||
throw new ServletException("No templateFile init-param found.");
|
||||
}
|
||||
String resourceBundle=config.getInitParameter("resourceBundle");
|
||||
if (resourceBundle==null) {
|
||||
throw new ServletException("No resourceBundle init-param found.");
|
||||
}
|
||||
ResourceBundle.getBundle(resourceBundle); // test if it loads
|
||||
servletContext=config.getServletContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
|
||||
*/
|
||||
public void doFilter(ServletRequest servletRequest,ServletResponse servletResponse,FilterChain chain) throws IOException, ServletException {
|
||||
|
||||
HttpServletRequest request = (HttpServletRequest)servletRequest;
|
||||
HttpServletResponse response = (HttpServletResponse)servletResponse;
|
||||
|
||||
// request info
|
||||
String path = request.getRequestURI();
|
||||
String v = "/vasc/";
|
||||
if (path.contains(v)) {
|
||||
path = path.substring(path.indexOf(v)+v.length());
|
||||
}
|
||||
|
||||
// stuff to fill
|
||||
String entityName = null;
|
||||
String actionName = null;
|
||||
String actionRecordId = null;
|
||||
|
||||
// parse request info
|
||||
//path = path.substring(1); // rm /
|
||||
int index = path.indexOf("/"); // check next /
|
||||
String actionString = null;
|
||||
if (index>0) {
|
||||
actionString = path.substring(index+1);
|
||||
entityName = path.substring(0,index);
|
||||
} else {
|
||||
entityName = path;
|
||||
}
|
||||
|
||||
if (actionString!=null) {
|
||||
index = actionString.indexOf("/");
|
||||
String recordString = null;
|
||||
if (index>0) {
|
||||
recordString = actionString.substring(index+1);
|
||||
actionName = actionString.substring(0,index);
|
||||
} else {
|
||||
actionName = actionString;
|
||||
}
|
||||
if (recordString!=null) {
|
||||
actionRecordId = recordString;
|
||||
}
|
||||
}
|
||||
|
||||
//log
|
||||
if (logger.isLoggable(Level.FINE)) {
|
||||
logger.log(Level.FINE,"entityName="+entityName+" actionName="+actionName+" actionRecordId="+actionRecordId);
|
||||
}
|
||||
|
||||
// Acquire the FacesContext instance for this request
|
||||
FacesContext facesContext = FacesContext.getCurrentInstance();
|
||||
if (facesContext == null) {
|
||||
FacesContextFactory facesContextFactory = (FacesContextFactory)FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
|
||||
LifecycleFactory lifecycleFactory = (LifecycleFactory)FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
|
||||
Lifecycle lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
|
||||
|
||||
facesContext = facesContextFactory.getFacesContext(servletContext, request, response, lifecycle);
|
||||
ProtectedFacesContext.setFacesContextAsCurrentInstance(facesContext);
|
||||
|
||||
UIViewRoot viewRoot = facesContext.getApplication().getViewHandler().createView(facesContext,entityName+actionName);
|
||||
facesContext.setViewRoot(viewRoot);
|
||||
}
|
||||
|
||||
// add to response
|
||||
request.setAttribute("requestScopeVascEntityName", entityName);
|
||||
request.setAttribute("requestScopeVascActionName", actionName);
|
||||
request.setAttribute("requestScopeVascRecordId" , actionRecordId);
|
||||
request.setAttribute("requestScopeVascPath" , request.getRequestURI());
|
||||
|
||||
// Set page title
|
||||
Locale locale = facesContext.getViewRoot().getLocale();
|
||||
if (locale==null) {
|
||||
logger.info("Failling back to defualt.");
|
||||
locale = new Locale("nl");
|
||||
}
|
||||
try {
|
||||
ResourceBundle i18n = ResourceBundle.getBundle(resourceBundle,locale);
|
||||
String titleI18n = i18n.getString("vasc.entry."+entityName+".name");
|
||||
request.setAttribute("requestScopeVascEntityNameI18n" ,titleI18n);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
request.setAttribute("requestScopeVascEntityNameI18n" ,entityName);
|
||||
}
|
||||
|
||||
try {
|
||||
request.getRequestDispatcher(templateFile).forward(request, response);
|
||||
} catch (ViewExpiredException e) {
|
||||
// lets try again
|
||||
response.sendRedirect(request.getRequestURL().toString());
|
||||
}
|
||||
// done
|
||||
}
|
||||
|
||||
private abstract static class ProtectedFacesContext extends FacesContext {
|
||||
protected static void setFacesContextAsCurrentInstance(FacesContext facesContext) {
|
||||
FacesContext.setCurrentInstance(facesContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.web.jsf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.faces.FacesException;
|
||||
import javax.faces.application.ViewHandler;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* Fixes the action url
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 May 05, 2009
|
||||
*/
|
||||
public class VascViewHandler extends ViewHandler {
|
||||
|
||||
private ViewHandler parentViewHandler = null;
|
||||
|
||||
|
||||
public VascViewHandler(ViewHandler viewHandler) {
|
||||
super();
|
||||
this.parentViewHandler = viewHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.application.ViewHandler#getActionURL(javax.faces.context.FacesContext, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public String getActionURL(FacesContext context, String name) {
|
||||
|
||||
HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
|
||||
if (request.getAttribute("requestScopeVascPath")==null) {
|
||||
return parentViewHandler.getActionURL(context, name);
|
||||
}
|
||||
String path = (String)request.getAttribute("requestScopeVascPath");
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.application.ViewHandler#calculateLocale(javax.faces.context.FacesContext)
|
||||
*/
|
||||
@Override
|
||||
public Locale calculateLocale(FacesContext context) {
|
||||
return parentViewHandler.calculateLocale(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.application.ViewHandler#calculateRenderKitId(javax.faces.context.FacesContext)
|
||||
*/
|
||||
@Override
|
||||
public String calculateRenderKitId(FacesContext context) {
|
||||
return parentViewHandler.calculateRenderKitId(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.application.ViewHandler#createView(javax.faces.context.FacesContext, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public UIViewRoot createView(FacesContext context, String name) {
|
||||
return parentViewHandler.createView(context, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.application.ViewHandler#getResourceURL(javax.faces.context.FacesContext, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public String getResourceURL(FacesContext context, String resource) {
|
||||
return parentViewHandler.getResourceURL(context, resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.application.ViewHandler#renderView(javax.faces.context.FacesContext, javax.faces.component.UIViewRoot)
|
||||
*/
|
||||
@Override
|
||||
public void renderView(FacesContext context, UIViewRoot viewRoot) throws IOException, FacesException {
|
||||
parentViewHandler.renderView(context, viewRoot);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.application.ViewHandler#restoreView(javax.faces.context.FacesContext, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public UIViewRoot restoreView(FacesContext context, String name) {
|
||||
return parentViewHandler.restoreView(context, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see javax.faces.application.ViewHandler#writeState(javax.faces.context.FacesContext)
|
||||
*/
|
||||
@Override
|
||||
public void writeState(FacesContext context) throws IOException {
|
||||
parentViewHandler.writeState(context);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.web.jsf.ui;
|
||||
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import net.forwardfire.vasc.core.ui.VascUIComponent;
|
||||
import net.forwardfire.vasc.frontends.web.jsf.JSFVascUIComponent;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Aug 8, 2009
|
||||
*/
|
||||
abstract public class AbstractJSFBaseComponent implements VascUIComponent {
|
||||
|
||||
protected String componentId = null;
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#getErrorText()
|
||||
*/
|
||||
public String getErrorText() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setErrorText(java.lang.String)
|
||||
*/
|
||||
public void setErrorText(String text) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isRendered()
|
||||
*/
|
||||
public boolean isRendered() {
|
||||
UIComponent component = (UIComponent)JSFVascUIComponent.findComponentById(FacesContext.getCurrentInstance().getViewRoot(),componentId);
|
||||
return component.isRendered();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setRendered(boolean)
|
||||
*/
|
||||
public void setRendered(boolean rendered) {
|
||||
// todo: disabled until templates fixes
|
||||
//UIComponent component = (UIComponent)net.forwardfire.vasc.frontends.web.jsf.VascUIComponent.findComponentById(FacesContext.getCurrentInstance().getViewRoot(),componentId);
|
||||
//component.setRendered(rendered);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.web.jsf.ui;
|
||||
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.component.html.HtmlSelectBooleanCheckbox;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
import net.forwardfire.vasc.frontends.web.jsf.JSFVascUIComponent;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 28, 2009
|
||||
*/
|
||||
public class JSFBoolean extends AbstractJSFBaseComponent {
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws VascException {
|
||||
Application application = FacesContext.getCurrentInstance().getApplication();
|
||||
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
|
||||
HtmlSelectBooleanCheckbox component = (HtmlSelectBooleanCheckbox)application.createComponent(HtmlSelectBooleanCheckbox.COMPONENT_TYPE);
|
||||
component.setId(viewRoot.createUniqueId());
|
||||
componentId = component.getId();
|
||||
|
||||
((UIComponent)gui).getChildren().add(component);
|
||||
return component;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isDisabled()
|
||||
*/
|
||||
public boolean isDisabled() {
|
||||
HtmlSelectBooleanCheckbox component = (HtmlSelectBooleanCheckbox)JSFVascUIComponent.findComponentById(FacesContext.getCurrentInstance().getViewRoot(),componentId);
|
||||
return component.isDisabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setDisabled(boolean)
|
||||
*/
|
||||
public void setDisabled(boolean disabled) {
|
||||
HtmlSelectBooleanCheckbox component = (HtmlSelectBooleanCheckbox)JSFVascUIComponent.findComponentById(FacesContext.getCurrentInstance().getViewRoot(),componentId);
|
||||
component.setDisabled(disabled);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.web.jsf.ui;
|
||||
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.component.html.HtmlOutputText;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 25, 2009
|
||||
*/
|
||||
public class JSFLabel extends AbstractJSFBaseComponent {
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws VascException {
|
||||
Application application = FacesContext.getCurrentInstance().getApplication();
|
||||
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
|
||||
HtmlOutputText component = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
|
||||
component.setId(viewRoot.createUniqueId());
|
||||
componentId = component.getId();
|
||||
component.setValue(""+model.getValue());
|
||||
((UIComponent)gui).getChildren().add(component);
|
||||
return component;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isDisabled()
|
||||
*/
|
||||
public boolean isDisabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setDisabled(boolean)
|
||||
*/
|
||||
public void setDisabled(boolean disabled) {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.web.jsf.ui;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import javax.el.ValueExpression;
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UISelectItems;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.component.html.HtmlSelectOneMenu;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.convert.Converter;
|
||||
import javax.faces.convert.ConverterException;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.ui.VascSelectItem;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
import net.forwardfire.vasc.frontends.web.jsf.JSFVascUIComponent;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 28, 2009
|
||||
*/
|
||||
public class JSFList extends AbstractJSFBaseComponent {
|
||||
|
||||
|
||||
public Object createComponent(VascEntry entry,VascEntryField entryField,VascValueModel model,Object gui) throws VascException {
|
||||
Application application = FacesContext.getCurrentInstance().getApplication();
|
||||
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
|
||||
HtmlSelectOneMenu component = (HtmlSelectOneMenu)application.createComponent(HtmlSelectOneMenu.COMPONENT_TYPE);
|
||||
component.setId(viewRoot.createUniqueId());
|
||||
componentId = component.getId();
|
||||
|
||||
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent((UIComponent)gui);
|
||||
String entrySupportVar = (String)comp.getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
|
||||
ValueExpression itemsTestVE = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".editSelectItemModels['jsfListItems_"+componentId+"']}", JSFListModel.class);
|
||||
|
||||
JSFListModel t = new JSFListModel(entryField);
|
||||
itemsTestVE.setValue(FacesContext.getCurrentInstance().getELContext(), t);
|
||||
|
||||
component.setConverter(new VascConverter(t));
|
||||
((UIComponent)gui).getChildren().add(component);
|
||||
|
||||
setValueTestModel(component);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isDisabled()
|
||||
*/
|
||||
public boolean isDisabled() {
|
||||
HtmlSelectOneMenu component = (HtmlSelectOneMenu)JSFVascUIComponent.findComponentById(FacesContext.getCurrentInstance().getViewRoot(),componentId);
|
||||
return component.isDisabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setDisabled(boolean)
|
||||
*/
|
||||
public void setDisabled(boolean disabled) {
|
||||
HtmlSelectOneMenu component = (HtmlSelectOneMenu)JSFVascUIComponent.findComponentById(FacesContext.getCurrentInstance().getViewRoot(),componentId);
|
||||
component.setDisabled(disabled);
|
||||
}
|
||||
|
||||
private void setValueTestModel(HtmlSelectOneMenu component) {
|
||||
Application application = FacesContext.getCurrentInstance().getApplication();
|
||||
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
|
||||
|
||||
UISelectItems item = (UISelectItems)application.createComponent(UISelectItems.COMPONENT_TYPE);
|
||||
item.setId(viewRoot.createUniqueId());
|
||||
|
||||
JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,null);
|
||||
String entrySupportVar = (String)comp.getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
|
||||
String id = component.getId();
|
||||
ValueExpression itemsVE = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(), "#{"+entrySupportVar+".editSelectItemModels['jsfListItems_"+id+"']}", List.class);
|
||||
item.setValueExpression("value", itemsVE);
|
||||
|
||||
component.getChildren().clear();
|
||||
component.getChildren().add(item);
|
||||
}
|
||||
}
|
||||
class VascConverter implements Converter,Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6198813637409531713L;
|
||||
private JSFListModel testModel = null;
|
||||
|
||||
public VascConverter(JSFListModel testModel) {
|
||||
this.testModel=testModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an ID to an Object
|
||||
*/
|
||||
public Object getAsObject(FacesContext context,UIComponent component,String value) throws ConverterException {
|
||||
if (context == null) { throw new NullPointerException("context may not be null"); }
|
||||
if (component == null) { throw new NullPointerException("component may not be null"); }
|
||||
if (value == null) { return null; }
|
||||
if ((value=value.trim()).length() == 0) { return null; }
|
||||
|
||||
for (VascSelectItem v:testModel.getVascItems()) {
|
||||
if (value.equals(v.getKeyValue())) {
|
||||
return v.getValue();
|
||||
}
|
||||
}
|
||||
throw new ConverterException("Could not convert value as object: "+value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an Object to an ID.
|
||||
*/
|
||||
public String getAsString(FacesContext context,UIComponent component,Object value) throws ConverterException {
|
||||
if (context == null) { throw new NullPointerException("context may not be null"); }
|
||||
if (component == null) { throw new NullPointerException("component may not be null"); }
|
||||
if (value == null) { return ""; }
|
||||
|
||||
for (VascSelectItem v:testModel.getVascItems()) {
|
||||
if (value.equals(v.getValue())) {
|
||||
return v.getKeyValue();
|
||||
}
|
||||
}
|
||||
throw new ConverterException("Could not convert value as string: "+value);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,182 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.web.jsf.ui;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import javax.faces.model.SelectItem;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.ui.VascSelectItem;
|
||||
import net.forwardfire.vasc.core.ui.VascSelectItemModel;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 28, 2009
|
||||
*/
|
||||
public class JSFListModel implements Serializable,List<SelectItem> {
|
||||
|
||||
private static final long serialVersionUID = -5266070864271715383L;
|
||||
private VascEntryField entryField;
|
||||
private List<VascSelectItem> items = null;
|
||||
private List<SelectItem> selectItems = null;
|
||||
private boolean refresh = true;
|
||||
|
||||
public JSFListModel() {
|
||||
items = new ArrayList<VascSelectItem>(40);
|
||||
selectItems = new ArrayList<SelectItem>(40);
|
||||
}
|
||||
|
||||
public JSFListModel(VascEntryField entryField) {
|
||||
this();
|
||||
this.entryField=entryField;
|
||||
}
|
||||
|
||||
public List<VascSelectItem> getVascItems() {
|
||||
refresh();
|
||||
return items;
|
||||
}
|
||||
|
||||
public List<SelectItem> getSelectItems() {
|
||||
refresh();
|
||||
return selectItems;
|
||||
}
|
||||
|
||||
public void requestRefresh() {
|
||||
refresh = true;
|
||||
}
|
||||
|
||||
private void refresh() {
|
||||
if (refresh==false) {
|
||||
return;
|
||||
}
|
||||
refresh=false;
|
||||
items.clear();
|
||||
selectItems.clear();
|
||||
|
||||
VascSelectItemModel itemModel = (VascSelectItemModel)entryField.getVascEntryFieldType().getDataObject();
|
||||
try {
|
||||
items = itemModel.getVascSelectItems(entryField.getVascEntry());
|
||||
} catch (VascException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
for (VascSelectItem v:items) {
|
||||
selectItems.add(convert(v));
|
||||
}
|
||||
}
|
||||
|
||||
private SelectItem convert(VascSelectItem v) {
|
||||
SelectItem si = new SelectItem();
|
||||
si.setLabel(v.getLabel());
|
||||
si.setValue(v.getValue());
|
||||
si.setDisabled(v.isDisabled());
|
||||
return si;
|
||||
}
|
||||
|
||||
// === LIST interface
|
||||
|
||||
public void add(int arg0, SelectItem arg1) {
|
||||
getSelectItems().add(arg0,arg1);
|
||||
}
|
||||
public boolean add(SelectItem arg0) {
|
||||
return getSelectItems().add(arg0);
|
||||
}
|
||||
public boolean addAll(Collection<? extends SelectItem> arg0) {
|
||||
return getSelectItems().addAll(arg0);
|
||||
}
|
||||
public boolean addAll(int arg0, Collection<? extends SelectItem> arg1) {
|
||||
return getSelectItems().addAll(arg0,arg1);
|
||||
}
|
||||
public void clear() {
|
||||
getSelectItems().clear();
|
||||
}
|
||||
public boolean contains(Object arg0) {
|
||||
return getSelectItems().contains(arg0);
|
||||
}
|
||||
public boolean containsAll(Collection<?> arg0) {
|
||||
return getSelectItems().containsAll(arg0);
|
||||
}
|
||||
public SelectItem get(int index) {
|
||||
return getSelectItems().get(index);
|
||||
}
|
||||
public int indexOf(Object arg0) {
|
||||
return getSelectItems().indexOf(arg0);
|
||||
}
|
||||
public boolean isEmpty() {
|
||||
return getSelectItems().isEmpty();
|
||||
}
|
||||
public Iterator<SelectItem> iterator() {
|
||||
return getSelectItems().iterator();
|
||||
}
|
||||
public int lastIndexOf(Object arg0) {
|
||||
return getSelectItems().lastIndexOf(arg0);
|
||||
}
|
||||
public ListIterator<SelectItem> listIterator() {
|
||||
return getSelectItems().listIterator();
|
||||
}
|
||||
public ListIterator<SelectItem> listIterator(int arg0) {
|
||||
return getSelectItems().listIterator(arg0);
|
||||
}
|
||||
public SelectItem remove(int arg0) {
|
||||
return getSelectItems().remove(arg0);
|
||||
}
|
||||
public boolean remove(Object arg0) {
|
||||
return getSelectItems().remove(arg0);
|
||||
}
|
||||
public boolean removeAll(Collection<?> arg0) {
|
||||
return getSelectItems().removeAll(arg0);
|
||||
}
|
||||
public boolean retainAll(Collection<?> arg0) {
|
||||
return getSelectItems().retainAll(arg0);
|
||||
}
|
||||
public SelectItem set(int arg0, SelectItem arg1) {
|
||||
return getSelectItems().set(arg0, arg1);
|
||||
}
|
||||
public int size() {
|
||||
return getSelectItems().size();
|
||||
}
|
||||
public List<SelectItem> subList(int arg0, int arg1) {
|
||||
return getSelectItems().subList(arg0, arg1);
|
||||
}
|
||||
public Object[] toArray() {
|
||||
return getSelectItems().toArray();
|
||||
}
|
||||
public <T> T[] toArray(T[] a) {
|
||||
return getSelectItems().toArray(a);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.web.jsf.ui;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.component.html.HtmlInputText;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.convert.Converter;
|
||||
import javax.faces.convert.ConverterException;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
import net.forwardfire.vasc.frontends.web.jsf.JSFVascUIComponent;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 25, 2009
|
||||
*/
|
||||
public class JSFText extends AbstractJSFBaseComponent {
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws VascException {
|
||||
Application application = FacesContext.getCurrentInstance().getApplication();
|
||||
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
|
||||
HtmlInputText component = (HtmlInputText)application.createComponent(HtmlInputText.COMPONENT_TYPE);
|
||||
component.setId(viewRoot.createUniqueId());
|
||||
componentId = component.getId();
|
||||
|
||||
component.setConverter(new VascNullConverter());
|
||||
|
||||
Integer sizeEdit = entryField.getSizeEdit();
|
||||
if (sizeEdit!=null) {
|
||||
component.setSize(sizeEdit);
|
||||
}
|
||||
((UIComponent)gui).getChildren().add(component);
|
||||
return component;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isDisabled()
|
||||
*/
|
||||
public boolean isDisabled() {
|
||||
HtmlInputText component = (HtmlInputText)JSFVascUIComponent.findComponentById(FacesContext.getCurrentInstance().getViewRoot(),componentId);
|
||||
return component.isDisabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setDisabled(boolean)
|
||||
*/
|
||||
public void setDisabled(boolean disabled) {
|
||||
HtmlInputText component = (HtmlInputText)JSFVascUIComponent.findComponentById(FacesContext.getCurrentInstance().getViewRoot(),componentId);
|
||||
component.setDisabled(disabled);
|
||||
}
|
||||
}
|
||||
class VascNullConverter implements Converter,Serializable {
|
||||
|
||||
private static final long serialVersionUID = 61988136374095313L;
|
||||
|
||||
/**
|
||||
* Convert an ID to an Object
|
||||
*/
|
||||
public Object getAsObject(FacesContext context,UIComponent component,String value) throws ConverterException {
|
||||
//System.out.println("getAsObject: "+component+" value: "+value);
|
||||
if (context == null) { throw new NullPointerException("context may not be null"); }
|
||||
if (component == null) { throw new NullPointerException("component may not be null"); }
|
||||
if (value == null) { return ""; }
|
||||
if ((value=value.trim()).length() == 0) { return ""; }
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an Object to an ID.
|
||||
*/
|
||||
public String getAsString(FacesContext context,UIComponent component,Object value) throws ConverterException {
|
||||
//System.out.println("getAsString: "+component+" value: "+value);
|
||||
if (context == null) { throw new NullPointerException("context may not be null"); }
|
||||
if (component == null) { throw new NullPointerException("component may not be null"); }
|
||||
if (value == null) { return ""; }
|
||||
return ""+value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Copyright 2004-2007 IDCA. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and
|
||||
* the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions
|
||||
* and the following disclaimer in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY IDCA AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL IDCA OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the authors and
|
||||
* should not be interpreted as representing official policies, either expressed or implied, of IDCA.
|
||||
*/
|
||||
|
||||
package net.forwardfire.vasc.frontends.web.jsf.ui;
|
||||
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.component.html.HtmlInputTextarea;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import net.forwardfire.vasc.core.VascEntry;
|
||||
import net.forwardfire.vasc.core.VascEntryField;
|
||||
import net.forwardfire.vasc.core.VascException;
|
||||
import net.forwardfire.vasc.core.ui.VascValueModel;
|
||||
import net.forwardfire.vasc.frontends.web.jsf.JSFVascUIComponent;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Mar 25, 2009
|
||||
*/
|
||||
public class JSFTextArea extends AbstractJSFBaseComponent {
|
||||
|
||||
public Object createComponent(VascEntry table,VascEntryField entryField,VascValueModel model,Object gui) throws VascException {
|
||||
Application application = FacesContext.getCurrentInstance().getApplication();
|
||||
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
|
||||
HtmlInputTextarea component = (HtmlInputTextarea)application.createComponent(HtmlInputTextarea.COMPONENT_TYPE);
|
||||
component.setId(viewRoot.createUniqueId());
|
||||
componentId = component.getId();
|
||||
|
||||
String cols = entryField.getVascEntryFieldType().getProperty("editor.columns");
|
||||
if (cols!=null && "".equals(cols)==false) {
|
||||
component.setCols(new Integer(cols));
|
||||
}
|
||||
String rows = entryField.getVascEntryFieldType().getProperty("editor.rows");
|
||||
if (rows!=null && "".equals(rows)==false) {
|
||||
component.setRows(new Integer(rows));
|
||||
}
|
||||
((UIComponent)gui).getChildren().add(component);
|
||||
return component;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#isDisabled()
|
||||
*/
|
||||
public boolean isDisabled() {
|
||||
HtmlInputTextarea component = (HtmlInputTextarea)JSFVascUIComponent.findComponentById(FacesContext.getCurrentInstance().getViewRoot(),componentId);
|
||||
return component.isDisabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see net.forwardfire.vasc.core.ui.VascUIComponent#setDisabled(boolean)
|
||||
*/
|
||||
public void setDisabled(boolean disabled) {
|
||||
HtmlInputTextarea component = (HtmlInputTextarea)JSFVascUIComponent.findComponentById(FacesContext.getCurrentInstance().getViewRoot(),componentId);
|
||||
component.setDisabled(disabled);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faces-config version="1.2" 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/web-facesconfig_1_2.xsd">
|
||||
|
||||
<!-- The New -->
|
||||
<component>
|
||||
<description><![CDATA[Renders a templated vasc entry]]></description>
|
||||
<display-name>Vasc JSF Component</display-name>
|
||||
<component-type>vasc.jsf.component</component-type>
|
||||
<component-class>net.forwardfire.vasc.frontends.web.jsf.JSFVascUIComponent</component-class>
|
||||
<component-extension>
|
||||
<renderer-type>vasc.jsf.component.renderer</renderer-type>
|
||||
</component-extension>
|
||||
</component>
|
||||
|
||||
<render-kit>
|
||||
<renderer>
|
||||
<component-family>vasc.jsf.component.family</component-family>
|
||||
<renderer-type>vasc.jsf.component.renderer</renderer-type>
|
||||
<renderer-class>net.forwardfire.vasc.frontends.web.jsf.JSFVascUIComponentRenderer</renderer-class>
|
||||
</renderer>
|
||||
</render-kit>
|
||||
|
||||
<application>
|
||||
<locale-config/>
|
||||
<view-handler>net.forwardfire.vasc.frontends.web.jsf.VascViewHandler</view-handler>
|
||||
</application>
|
||||
|
||||
<factory/>
|
||||
|
||||
<lifecycle/>
|
||||
|
||||
</faces-config>
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE facelet-taglib PUBLIC "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" "http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
|
||||
<facelet-taglib>
|
||||
<namespace>http://vasc.idcanet.com/vasc.tld</namespace>
|
||||
<tag>
|
||||
<tag-name>vascEntry</tag-name>
|
||||
<component>
|
||||
<component-type>vasc.jsf.component</component-type>
|
||||
<renderer-type>vasc.jsf.component.renderer</renderer-type>
|
||||
</component>
|
||||
</tag>
|
||||
</facelet-taglib>
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<taglib version="2.0" 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 web-jsptaglibrary_2_0.xsd">
|
||||
<description>Vasc JSF 2.1 library</description>
|
||||
<display-name>Vasc</display-name>
|
||||
<tlib-version>2.1</tlib-version>
|
||||
<short-name>vasc</short-name>
|
||||
<uri>http://vasc.idcanet.com/vasc.tld</uri>
|
||||
<!-- DROPED JSP Support until <deferred-value> is fixed for jbossas6
|
||||
<tag>
|
||||
<description>Renders the vasc entry JSF Frontend Renderer</description>
|
||||
<name>vascEntry</name>
|
||||
<tag-class>net.forwardfire.vasc.frontends.web.jsf.JSFVascUIComponentTag</tag-class>
|
||||
<body-content>JSP</body-content>
|
||||
<attribute>
|
||||
<name>id</name>
|
||||
<required>false</required>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<name>rendered</name>
|
||||
<required>false</required>
|
||||
<deferred-value>
|
||||
<type>boolean</type>
|
||||
</deferred-value>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<name>binding</name>
|
||||
<required>false</required>
|
||||
<deferred-value>
|
||||
<type>javax.faces.component.UIComponent</type>
|
||||
</deferred-value>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<name>vascController</name>
|
||||
<required>true</required>
|
||||
<deferred-value>
|
||||
<type>net.forwardfire.vasc.core.VascController</type>
|
||||
</deferred-value>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<name>entryName</name>
|
||||
<required>false</required>
|
||||
<deferred-value>
|
||||
<type>java.lang.String</type>
|
||||
</deferred-value>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<name>vascFrontendData</name>
|
||||
<required>true</required>
|
||||
<deferred-value>
|
||||
<type>net.forwardfire.vasc.core.VascFrontendData</type>
|
||||
</deferred-value>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<name>entrySupportVar</name>
|
||||
<required>true</required>
|
||||
<deferred-value>
|
||||
<type>java.lang.String</type>
|
||||
</deferred-value>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<name>tableRecordVar</name>
|
||||
<required>true</required>
|
||||
<deferred-value>
|
||||
<type>java.lang.String</type>
|
||||
</deferred-value>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<name>injectEditFieldsId</name>
|
||||
<required>true</required>
|
||||
<deferred-value>
|
||||
<type>java.lang.String</type>
|
||||
</deferred-value>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<name>injectTableOptionsId</name>
|
||||
<required>true</required>
|
||||
<deferred-value>
|
||||
<type>java.lang.String</type>
|
||||
</deferred-value>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<name>injectTableColumnsId</name>
|
||||
<required>true</required>
|
||||
<deferred-value>
|
||||
<type>java.lang.String</type>
|
||||
</deferred-value>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<name>disableLinkColumns</name>
|
||||
<required>false</required>
|
||||
<deferred-value>
|
||||
<type>java.lang.String</type>
|
||||
</deferred-value>
|
||||
</attribute>
|
||||
</tag>
|
||||
-->
|
||||
</taglib>
|
||||
Loading…
Add table
Add a link
Reference in a new issue