2
0
Fork 0

Refactored internal api

This commit is contained in:
Willem Cazander 2012-06-04 22:49:12 +02:00
parent 3f31bb8a3a
commit 6ccd763d1f
361 changed files with 23049 additions and 4498 deletions

View file

@ -20,46 +20,30 @@
<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>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api.version}</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<version>${jstl.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<version>${jsp-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>1.2_04</version>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>${javax.faces.version}</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>

View file

@ -29,7 +29,8 @@ import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.core.VascController;
import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryField;
import net.forwardfire.vasc.frontend.VascFrontendData;
import net.forwardfire.vasc.core.VascEntryLocal;
import net.forwardfire.vasc.frontend.VascFrontendController;
import net.forwardfire.vasc.impl.DefaultVascFactory;
/**
@ -40,7 +41,7 @@ import net.forwardfire.vasc.impl.DefaultVascFactory;
*/
public abstract class AbstractJSFVascFacesControllerBase {
abstract public VascFrontendData getNewVascFrontendData();
abstract public VascFrontendController getNewVascFrontendData();
abstract public VascController getVascController();
public void setVascController(VascController vascController) {
@ -52,18 +53,24 @@ public abstract class AbstractJSFVascFacesControllerBase {
public List<Object> executeVascList(String entryId,Map<String,Object> para) {
try {
// plug all object
VascEntry entry = getVascController().getVascEntryController().getVascEntryById(entryId);
DefaultVascFactory.fillVascEntryFrontend(entry, getVascController(), getNewVascFrontendData());
VascEntryLocal entry = (VascEntryLocal)getVascController().getVascEntryController().getVascEntryById(entryId);
getVascController().getVascEntryConfigController().configVascFrontendController(getVascController(), entry);
// set def para
VascBackendState state = entry.getVascFrontendData().getVascEntryState().getVascBackendState();
VascBackendState state = entry.getVascFrontendController().getVascEntryState().getVascBackendState();
for (String key2:entry.getEntryParameterKeys()) {
Object value = entry.getEntryParameter(key2);
state.setDataParameter(key2, value);
}
// copy para
if (para!=null) {
for (String key:para.keySet()) {
state.setDataParameter(key, para.get(key));
}
}
// set list para
for (VascEntryField vef:entry.getListOptions()) {
for (VascEntryField vef:entry.getVascEntryListOptions()) {
Object def = vef.getDefaultValue();
if (def==null) {
continue;
@ -72,16 +79,9 @@ public abstract class AbstractJSFVascFacesControllerBase {
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().getVascFrontendActions().refreshData();
return entry.getVascFrontendData().getVascEntryState().getEntryDataList();
entry.getVascFrontendController().getVascFrontendActions().refreshData();
return entry.getVascFrontendController().getVascEntryState().getEntryDataList();
} catch (Exception e) {
throw new RuntimeException("Could not execute list: "+e.getMessage(),e);
}

View file

@ -45,12 +45,13 @@ 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.VascEntryLocal;
import net.forwardfire.vasc.core.VascException;
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.frontend.VascFrontendData;
import net.forwardfire.vasc.frontend.VascFrontendController;
import net.forwardfire.vasc.impl.DefaultVascFactory;
import net.forwardfire.vasc.impl.entry.DefaultVascEntryResourceResolver;
import net.forwardfire.vasc.impl.entry.SetParameterBackendListener;
@ -125,9 +126,8 @@ abstract public class AbstractJSFVascFacesControllerEJB extends AbstractJSFVascF
/**
* Config vasc frontend data object for jsf component to use.
*
* @return
*/
public VascFrontendData getNewVascFrontendData() {
public VascFrontendController getNewVascFrontendData() {
Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
MergedResourceBundle bundle = new MergedResourceBundle();
bundle.addDataBundle(ResourceBundle.getBundle(getResourceBundleWEB(), locale));
@ -141,7 +141,7 @@ abstract public class AbstractJSFVascFacesControllerEJB extends AbstractJSFVascF
throw new RuntimeException("Could not get the ejb resource bundle: "+e.getMessage(),e);
}
VascFrontendData vascFrontendData = DefaultVascFactory.getDefaultVascFrontendData(bundle);
VascFrontendController vascFrontendData = DefaultVascFactory.getDefaultVascFrontendData(bundle);
vascFrontendData.addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() {
private static final long serialVersionUID = 1L;
public VascFrontendEventType[] getEventTypes() {
@ -154,7 +154,7 @@ abstract public class AbstractJSFVascFacesControllerEJB extends AbstractJSFVascF
}
}
});
// config frontend data for ISF usage
if (getDisableI18N()) {
vascFrontendData.setVascEntryResourceResolver(new DefaultVascEntryResourceResolver());
@ -163,7 +163,9 @@ abstract public class AbstractJSFVascFacesControllerEJB extends AbstractJSFVascF
}
return vascFrontendData;
}
* @return
*/
class RemoteVascBackend implements VascBackend {
@ -279,10 +281,10 @@ abstract public class AbstractJSFVascFacesControllerEJB extends AbstractJSFVascF
}
public VascEntryRecordCreator provideVascEntryRecordCreator(VascEntry vascEntry) {
VascEntry clone = null;
VascEntryLocal clone = null;
try {
clone = vascEntry.clone();
clone.setVascFrontendData(null);
clone = ((VascEntryLocal)vascEntry).clone();
clone.setVascFrontendController(null);
clone.setVascEntryFieldEventChannel(null);
} catch (CloneNotSupportedException e) {
// TODO Auto-generated catch block
@ -345,7 +347,7 @@ abstract public class AbstractJSFVascFacesControllerEJB extends AbstractJSFVascF
// get local jvm plugging controller
VascController c = DefaultVascFactory.getDefaultVascController(vui.userId, vui.username, vui.roles);
VascController c = DefaultVascFactory.getDefaultVascController();
/*
DefaultVascEntryController con = new DefaultVascEntryController() {
@ -366,7 +368,7 @@ abstract public class AbstractJSFVascFacesControllerEJB extends AbstractJSFVascF
VascEntryControllerLocal localEntryController = (VascEntryControllerLocal)c.getVascEntryController();
VascBackendControllerLocal localBackendController = (VascBackendControllerLocal)c.getVascBackendController();
for (String id:entryIds) {
VascEntry ve = vascManager.getVascEntry(id);
VascEntryLocal ve = (VascEntryLocal)vascManager.getVascEntry(id);
String backendId = ve.getBackendId();
VascBackend vb = new RemoteVascBackend(backendId,vascManager);

View file

@ -36,7 +36,7 @@ import net.forwardfire.vasc.core.VascController;
import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryControllerLocal;
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
import net.forwardfire.vasc.frontend.VascFrontendData;
import net.forwardfire.vasc.frontend.VascFrontendController;
import net.forwardfire.vasc.impl.DefaultVascFactory;
import net.forwardfire.vasc.impl.entry.DefaultVascEntryResourceResolver;
import net.forwardfire.vasc.impl.x4o.VascParser;
@ -93,15 +93,13 @@ abstract public class AbstractJSFVascFacesControllerLocal extends AbstractJSFVas
/**
* Config vasc frontend data object for jsf component to use.
*
* @return
*/
public VascFrontendData getNewVascFrontendData() {
public VascFrontendController getNewVascFrontendData() {
Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
MergedResourceBundle bundle = new MergedResourceBundle();
bundle.addDataBundle(ResourceBundle.getBundle(getResourceBundleWEB(), locale));
VascFrontendData vascFrontendData = DefaultVascFactory.getDefaultVascFrontendData(bundle);
VascFrontendController vascFrontendData = DefaultVascFactory.getDefaultVascFrontendData(bundle);
vascFrontendData.addVascEntryFrontendEventListener(new VascEntryFrontendEventListener() {
private static final long serialVersionUID = 1L;
public VascFrontendEventType[] getEventTypes() {
@ -123,6 +121,9 @@ abstract public class AbstractJSFVascFacesControllerLocal extends AbstractJSFVas
}
return vascFrontendData;
}
*
* @return
*/
/**
* @return the vascController
@ -134,7 +135,7 @@ abstract public class AbstractJSFVascFacesControllerLocal extends AbstractJSFVas
try {
// get local jvm plugging controller
VascUserInfo vui = getVascUserInfo();
VascController c = DefaultVascFactory.getDefaultVascController(vui.userId, vui.username, vui.roles);
VascController c = DefaultVascFactory.getDefaultVascController();
// Load vasc resources
for (String res:getVascParseResources()) {

View file

@ -74,7 +74,7 @@ public class JSFVascEntryEventListener implements VascEntryFrontendEventListener
throw new RuntimeException(e);
}
*/
List<Object> data = entry.getVascFrontendData().getVascEntryState().getEntryDataList();
List<Object> data = entry.getVascFrontendController().getVascEntryState().getEntryDataList();
List<Object> result = new ArrayList<Object>(data.size());
int index = 0;
for (Object o:data) {
@ -86,6 +86,6 @@ public class JSFVascEntryEventListener implements VascEntryFrontendEventListener
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().getVascFrontendPager().getTablePagesFromBackend());
ve3.setValue(FacesContext.getCurrentInstance().getELContext(), entry.getVascFrontendController().getVascFrontendPager().getTablePagesFromBackend());
}
}

View file

@ -52,8 +52,8 @@ import net.forwardfire.vasc.backend.VascBackendPageNumber;
import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryField;
import net.forwardfire.vasc.core.VascEntryState;
import net.forwardfire.vasc.core.VascLinkEntry;
import net.forwardfire.vasc.core.VascLinkEntryType;
import net.forwardfire.vasc.core.VascEntryLink;
import net.forwardfire.vasc.core.VascEntryLinkType;
import net.forwardfire.vasc.core.actions.GlobalVascAction;
import net.forwardfire.vasc.core.actions.RowVascAction;
import net.forwardfire.vasc.core.entry.VascEntryExporter;
@ -104,7 +104,7 @@ public class JSFVascEntrySupportBean implements Serializable {
editSelectItemModels = new HashMap<String,Object>(6);
// cache some values
VascBackend backend = entry.getVascFrontendData().getVascEntryState().getVascBackend();
VascBackend backend = entry.getVascFrontendController().getVascEntryState().getVascBackend();
backendPageable = backend.isPageable();
backendMoveable = backend.isRecordMoveable();
backendSearchable = backend.isSearchable();
@ -134,11 +134,11 @@ public class JSFVascEntrySupportBean implements Serializable {
}
public String getParentSelectedDisplayName() {
return entry.getVascFrontendData().getVascFrontendHelper().getParentSelectedDisplayName(entry);
return entry.getVascFrontendController().getVascFrontendHelper().getParentSelectedDisplayName(entry);
}
public String getSelectedDisplayName() {
return entry.getVascFrontendData().getVascFrontendHelper().getSelectedDisplayName(entry);
return entry.getVascFrontendController().getVascFrontendHelper().getSelectedDisplayName(entry);
}
public int getTotalColumnCount() {
@ -155,7 +155,7 @@ public class JSFVascEntrySupportBean implements Serializable {
t++; // auto add of select boxes
}
for (VascEntryField c:entry.getVascEntryFields()) {
if (entry.getVascFrontendData().getVascFrontendHelper().renderList(c)==false) {
if (entry.getVascFrontendController().getVascFrontendDataSelector().isFieldList(c)==false) {
continue;
}
t++;
@ -165,7 +165,7 @@ public class JSFVascEntrySupportBean implements Serializable {
public int getTotalActionColumnCount() {
int t = 0;
if (entry.getVascFrontendData().getVascEntryState().getVascBackend().isRecordMoveable()) {
if (entry.getVascFrontendController().getVascEntryState().getVascBackend().isRecordMoveable()) {
t++;
t++;
}
@ -177,33 +177,33 @@ public class JSFVascEntrySupportBean implements Serializable {
return getVascLinkEntriesList().size();
}
public List<VascLinkEntry> getVascLinkEntriesList() {
return entry.getVascFrontendData().getVascFrontendHelper().getVascLinkEntryByType(entry,VascLinkEntryType.LIST);
public List<VascEntryLink> getVascLinkEntriesList() {
return entry.getVascFrontendController().getVascFrontendHelper().getVascLinkEntryByType(entry,VascEntryLinkType.LIST);
}
public List<VascLinkEntry> getVascLinkEntriesEditTab() {
return entry.getVascFrontendData().getVascFrontendHelper().getVascLinkEntryByType(entry,VascLinkEntryType.EDIT_TAB);
public List<VascEntryLink> getVascLinkEntriesEditTab() {
return entry.getVascFrontendController().getVascFrontendHelper().getVascLinkEntryByType(entry,VascEntryLinkType.EDIT_TAB);
}
public List<VascLinkEntry> getVascLinkEntriesEditInline() {
return entry.getVascFrontendData().getVascFrontendHelper().getVascLinkEntryByType(entry,VascLinkEntryType.EDIT_INLINE);
public List<VascEntryLink> getVascLinkEntriesEditInline() {
return entry.getVascFrontendController().getVascFrontendHelper().getVascLinkEntryByType(entry,VascEntryLinkType.EDIT_INLINE);
}
public List<VascLinkEntry> getVascLinkEntriesEditTabParentState() {
if (entry.getVascFrontendData().getVascEntryState().getParent()==null) {
List<VascLinkEntry> result = new ArrayList<VascLinkEntry>(0);
public List<VascEntryLink> getVascLinkEntriesEditTabParentState() {
if (entry.getVascFrontendController().getVascEntryState().getParent()==null) {
List<VascEntryLink> result = new ArrayList<VascEntryLink>(0);
return result;
}
return entry.getVascFrontendData().getVascFrontendHelper().getVascLinkEntryByType(entry.getVascFrontendData().getVascEntryState().getParent().getVascEntry(),VascLinkEntryType.EDIT_TAB);
return entry.getVascFrontendController().getVascFrontendHelper().getVascLinkEntryByType(entry.getVascFrontendController().getVascEntryState().getParent().getVascEntry(),VascEntryLinkType.EDIT_TAB);
}
public long getPageTotalRecordCount() {
return entry.getVascFrontendData().getVascFrontendPager().getPageTotalRecordCount();
return entry.getVascFrontendController().getVascFrontendPager().getPageTotalRecordCount();
}
public long getPageStartCount() {
return entry.getVascFrontendData().getVascFrontendPager().getPageStartCount();
return entry.getVascFrontendController().getVascFrontendPager().getPageStartCount();
}
public long getPageStopCount() {
return entry.getVascFrontendData().getVascFrontendPager().getPageStopCount();
return entry.getVascFrontendController().getVascFrontendPager().getPageStopCount();
}
public List<SelectItem> getGlobalExportItems() {
@ -232,7 +232,7 @@ public class JSFVascEntrySupportBean implements Serializable {
s.setValue("null");
result.add(s);
int pageSize = getVascEntry().getVascFrontendData().getVascEntryState().getVascBackendState().getPageSize();
int pageSize = getVascEntry().getVascFrontendController().getVascEntryState().getVascBackendState().getPageSize();
for (int i=0;i<getTablePagesDataModel().getRowCount();i++) {
getTablePagesDataModel().setRowIndex(i);
VascBackendPageNumber page = (VascBackendPageNumber)getTablePagesDataModel().getRowData();
@ -249,27 +249,27 @@ public class JSFVascEntrySupportBean implements Serializable {
}
public boolean getHasOnlySinglePage() {
return entry.getVascFrontendData().getVascFrontendPager().getHasOnlySinglePage();
return entry.getVascFrontendController().getVascFrontendPager().getHasOnlySinglePage();
}
public boolean getHasExtendedPageMode() {
return entry.getVascFrontendData().getVascFrontendPager().getHasExtendedPageMode();
return entry.getVascFrontendController().getVascFrontendPager().getHasExtendedPageMode();
}
public boolean getHasExtendedPageModeCenter() {
return entry.getVascFrontendData().getVascFrontendPager().getHasExtendedPageModeCenter();
return entry.getVascFrontendController().getVascFrontendPager().getHasExtendedPageModeCenter();
}
public List<VascBackendPageNumber> getTablePagesExtendedBegin() {
return entry.getVascFrontendData().getVascFrontendPager().getTablePagesExtendedBegin();
return entry.getVascFrontendController().getVascFrontendPager().getTablePagesExtendedBegin();
}
public List<VascBackendPageNumber> getTablePagesExtendedEnd() {
return entry.getVascFrontendData().getVascFrontendPager().getTablePagesExtendedEnd();
return entry.getVascFrontendController().getVascFrontendPager().getTablePagesExtendedEnd();
}
public List<VascBackendPageNumber> getTablePagesExtendedCenter() {
return entry.getVascFrontendData().getVascFrontendPager().getTablePagesExtendedCenter();
return entry.getVascFrontendController().getVascFrontendPager().getTablePagesExtendedCenter();
}
private String getComponentType(UIComponent comp) {
@ -285,10 +285,10 @@ public class JSFVascEntrySupportBean implements Serializable {
public List<RowVascAction> getParentCustomRowActions() {
List<RowVascAction> result = new ArrayList<RowVascAction>(5);
VascEntry entry = getVascEntry();
if (entry.getVascFrontendData().getVascEntryState().getParent()==null) {
if (entry.getVascFrontendController().getVascEntryState().getParent()==null) {
return result;
}
VascEntry parent = entry.getVascFrontendData().getVascEntryState().getParent().getVascEntry();
VascEntry parent = entry.getVascFrontendController().getVascEntryState().getParent().getVascEntry();
for (RowVascAction action:parent.getRowActions()) {
String actionId = action.getId();
if (AddRowAction.ACTION_ID.equals(actionId)) {
@ -310,25 +310,25 @@ public class JSFVascEntrySupportBean implements Serializable {
logger.fine("parentCustomRowaction: "+actionIdString);
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascEntry entry = comp.getVascEntry();
if (entry.getVascFrontendData().getVascEntryState().getParent()==null) {
if (entry.getVascFrontendController().getVascEntryState().getParent()==null) {
return;
}
VascEntry parent = entry.getVascFrontendData().getVascEntryState().getParent().getVascEntry();
VascEntry parent = entry.getVascFrontendController().getVascEntryState().getParent().getVascEntry();
RowVascAction action = parent.getRowActionById(actionIdString);
Object parentSelected = entry.getVascFrontendData().getVascEntryState().getParent().getEntryDataObject();
Object parentSelected = entry.getVascFrontendController().getVascEntryState().getParent().getEntryDataObject();
logger.fine("parentCustomRowaction do on: "+action+" parentSelection: "+parentSelected);
try {
action.doRowAction(parent,parentSelected);
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e);
}
logger.fine("parentCustomRowaction DONE");
}
public boolean getHasMultiRowActions() {
int size = getVascEntry().getVascFrontendData().getVascFrontendHelper().getMultiRowActions(getVascEntry()).size();
int size = getVascEntry().getVascFrontendController().getVascFrontendHelper().getMultiRowActions(getVascEntry()).size();
if (size==0) {
return false;
}
@ -343,7 +343,7 @@ public class JSFVascEntrySupportBean implements Serializable {
s.setValue("null");
result.add(s);
for (RowVascAction a:getVascEntry().getVascFrontendData().getVascFrontendHelper().getMultiRowActions(getVascEntry())) {
for (RowVascAction a:getVascEntry().getVascFrontendController().getVascFrontendHelper().getMultiRowActions(getVascEntry())) {
s = new SelectItem();
s.setLabel(i18nMap.get(a.getName()));
s.setDescription(i18nMap.get(a.getDescription()));
@ -390,7 +390,7 @@ public class JSFVascEntrySupportBean implements Serializable {
return;
}
RowVascAction action = vascEntry.getRowActionById(actionId);
VascEntryState state = vascEntry.getVascFrontendData().getVascEntryState();
VascEntryState state = vascEntry.getVascFrontendController().getVascEntryState();
try {
setSelectedMultiRowAction("null"); // reset to selected ... value
@ -427,7 +427,7 @@ public class JSFVascEntrySupportBean implements Serializable {
logger.fine("searchAction");
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascEntry entry = comp.getVascEntry();
entry.getVascFrontendData().getVascFrontendActions().searchAction(searchString);
entry.getVascFrontendController().getVascFrontendActions().searchAction(searchString);
}
public void sortAction(ActionEvent event) {
@ -436,18 +436,18 @@ public class JSFVascEntrySupportBean implements Serializable {
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascEntry entry = comp.getVascEntry();
VascEntryField field = entry.getVascEntryFieldById(fieldIdString);
entry.getVascFrontendData().getVascFrontendActions().sortAction(field);
sortOrder = entry.getVascFrontendData().getVascEntryState().getVascBackendState().isSortAscending();
entry.getVascFrontendController().getVascFrontendActions().sortAction(field);
sortOrder = entry.getVascFrontendController().getVascEntryState().getVascBackendState().isSortAscending();
sortField = field.getId();
}
public boolean getRenderBackAction() {
return getVascEntry().getVascFrontendData().getVascEntryState().getParent()!=null;
return getVascEntry().getVascFrontendController().getVascEntryState().getParent()!=null;
}
public boolean getRenderBackEditAction() {
if (getVascEntry().getVascFrontendData().getVascEntryState().getParent()!=null) {
if (getVascEntry().getVascFrontendData().getVascEntryState().getParent().getVascEntry().getRowActionById("editRowAction")==null) {
if (getVascEntry().getVascFrontendController().getVascEntryState().getParent()!=null) {
if (getVascEntry().getVascFrontendController().getVascEntryState().getParent().getVascEntry().getRowActionById("editRowAction")==null) {
return false; // parent is not editable
}
return true;
@ -458,11 +458,11 @@ public class JSFVascEntrySupportBean implements Serializable {
public void backAction(ActionEvent event) {
logger.fine("backAction");
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
comp.initGoto(entry.getVascFrontendData().getVascEntryState().getParent());
comp.initGoto(entry.getVascFrontendController().getVascEntryState().getParent());
try {
entry.getVascFrontendData().getVascFrontend().renderView();
entry.getVascFrontendController().getVascFrontend().renderView();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e);
}
}
@ -472,8 +472,8 @@ public class JSFVascEntrySupportBean implements Serializable {
VascEntry entry = getVascEntry();
// select record to edit
Object rowObject = entry.getVascFrontendData().getVascEntryState().getParent().getEntryDataObject();
comp.initGoto(entry.getVascFrontendData().getVascEntryState().getParent(),rowObject);
Object rowObject = entry.getVascFrontendController().getVascEntryState().getParent().getEntryDataObject();
comp.initGoto(entry.getVascFrontendController().getVascEntryState().getParent(),rowObject);
}
@ -483,7 +483,7 @@ public class JSFVascEntrySupportBean implements Serializable {
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascEntry entry = comp.getVascEntry();
selectedDirectPage=pageIndex+"";
entry.getVascFrontendData().getVascFrontendActions().pageAction(pageIndex);
entry.getVascFrontendController().getVascFrontendActions().pageAction(pageIndex);
}
public void pageNextAction(ActionEvent event) {
@ -491,14 +491,14 @@ public class JSFVascEntrySupportBean implements Serializable {
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascEntry entry = comp.getVascEntry();
int pageIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
int pageIndex = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageIndex();
pageIndex++;
selectedDirectPage=pageIndex+"";
entry.getVascFrontendData().getVascFrontendActions().pageAction(pageIndex);
entry.getVascFrontendController().getVascFrontendActions().pageAction(pageIndex);
try {
entry.getVascFrontendData().getVascFrontend().renderView();
entry.getVascFrontendController().getVascFrontend().renderView();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e);
}
}
@ -507,23 +507,23 @@ public class JSFVascEntrySupportBean implements Serializable {
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascEntry entry = comp.getVascEntry();
int pageIndex = entry.getVascFrontendData().getVascEntryState().getVascBackendState().getPageIndex();
int pageIndex = entry.getVascFrontendController().getVascEntryState().getVascBackendState().getPageIndex();
pageIndex--;
selectedDirectPage=pageIndex+"";
entry.getVascFrontendData().getVascFrontendActions().pageAction(pageIndex);
entry.getVascFrontendController().getVascFrontendActions().pageAction(pageIndex);
try {
entry.getVascFrontendData().getVascFrontend().renderView();
entry.getVascFrontendController().getVascFrontend().renderView();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e);
}
}
public boolean getHasPageNextAction() {
return entry.getVascFrontendData().getVascFrontendPager().getHasPageNextAction();
return entry.getVascFrontendController().getVascFrontendPager().getHasPageNextAction();
}
public boolean getHasPagePreviousAction() {
return entry.getVascFrontendData().getVascFrontendPager().getHasPagePreviousAction();
return entry.getVascFrontendController().getVascFrontendPager().getHasPagePreviousAction();
}
@ -547,7 +547,7 @@ public class JSFVascEntrySupportBean implements Serializable {
action.doRowAction(entry, selected.getRecord());
}
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e);
}
logger.fine("RowAction DONE");
}
@ -561,7 +561,7 @@ public class JSFVascEntrySupportBean implements Serializable {
try {
action.doGlobalAction(entry);
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e);
}
}
@ -574,7 +574,7 @@ public class JSFVascEntrySupportBean implements Serializable {
try {
action.doRowAction(entry, null);
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e);
}
}
@ -585,13 +585,13 @@ public class JSFVascEntrySupportBean implements Serializable {
VascDataBackendBean selected = comp.getSupportBean().getSelectedTableRecord();
logger.finer("Set selected: "+selected);
VascEntry entry = comp.getVascEntry();
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(selected.getRecord());
VascLinkEntry l = entry.getVascLinkEntryById(linkId);
entry.getVascFrontendController().getVascEntryState().setEntryDataObject(selected.getRecord());
VascEntryLink l = entry.getVascEntryLinkById(linkId);
comp.initGoto(l);
try {
entry.getVascFrontendData().getVascFrontend().renderView();
entry.getVascFrontendController().getVascFrontend().renderView();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e);
}
this.selected=selected; // renderView clears selected !
}
@ -602,10 +602,10 @@ public class JSFVascEntrySupportBean implements Serializable {
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
Object selected = comp.getSupportBean().getSelectedTableRecord().getRecord();
if ("up".equals(moveAction)) {
entry.getVascFrontendData().getVascFrontendActions().moveUpAction(selected);
entry.getVascFrontendController().getVascFrontendActions().moveUpAction(selected);
}
if ("down".equals(moveAction)) {
entry.getVascFrontendData().getVascFrontendActions().moveDownAction(selected);
entry.getVascFrontendController().getVascFrontendActions().moveDownAction(selected);
}
}
@ -616,12 +616,12 @@ public class JSFVascEntrySupportBean implements Serializable {
VascDataBackendBean selected = this.selected;
logger.fine("Set selected: "+selected);
VascEntry entry = comp.getVascEntry();
VascLinkEntry l = entry.getVascLinkEntryById(linkId);
VascEntryLink l = entry.getVascEntryLinkById(linkId);
comp.initGoto(l);
try {
entry.getVascFrontendData().getVascFrontend().renderView();
entry.getVascFrontendController().getVascFrontend().renderView();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e);
}
this.selected=selected; // renderView clears selected !
}
@ -630,17 +630,17 @@ public class JSFVascEntrySupportBean implements Serializable {
logger.fine("linkListAction");
String linkId = getComponentType(event.getComponent());
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascLinkEntry link = comp.getVascEntry().getVascFrontendData().getVascEntryState().getParent().getVascEntry().getVascLinkEntryById(linkId);
comp.initGoto(link,comp.getVascEntry().getVascFrontendData().getVascEntryState().getParent());
VascEntryLink link = comp.getVascEntry().getVascFrontendController().getVascEntryState().getParent().getVascEntry().getVascEntryLinkById(linkId);
comp.initGoto(link,comp.getVascEntry().getVascFrontendController().getVascEntryState().getParent());
Object o = comp.getVascEntry().getVascFrontendData().getVascEntryState().getParent().getEntryDataObject();
int index = comp.getVascEntry().getVascFrontendData().getVascEntryState().getParent().getEntryDataList().indexOf(o);
Object o = comp.getVascEntry().getVascFrontendController().getVascEntryState().getParent().getEntryDataObject();
int index = comp.getVascEntry().getVascFrontendController().getVascEntryState().getParent().getEntryDataList().indexOf(o);
VascDataBackendBean selected = new VascDataBackendBean(entry,o,index);
this.selected=selected;
try {
entry.getVascFrontendData().getVascFrontend().renderView();
entry.getVascFrontendController().getVascFrontend().renderView();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e);
}
this.selected=selected;
}
@ -652,11 +652,11 @@ public class JSFVascEntrySupportBean implements Serializable {
if (getSelected()!=null) {
getSelected().setRealValue(false);
}
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(null);
entry.getVascFrontendController().getVascEntryState().setEntryDataObject(null);
try {
entry.getVascFrontendData().getVascFrontend().renderView();
entry.getVascFrontendController().getVascFrontend().renderView();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e);
}
}
@ -679,18 +679,18 @@ public class JSFVascEntrySupportBean implements Serializable {
}
*/
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(selected.getRecord());
entry.getVascFrontendController().getVascEntryState().setEntryDataObject(selected.getRecord());
if (entry.getVascFrontendData().getVascEntryState().isEditCreate()) {
entry.getVascFrontendData().getVascFrontendActions().persistObject();
if (entry.getVascFrontendController().getVascEntryState().isEditCreate()) {
entry.getVascFrontendController().getVascFrontendActions().persistObject();
} else {
entry.getVascFrontendData().getVascFrontendActions().mergeObject();
entry.getVascFrontendController().getVascFrontendActions().mergeObject();
}
try {
entry.getVascFrontendData().getVascFrontend().renderView();
entry.getVascFrontendController().getVascFrontend().renderView();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e);
}
}
@ -698,7 +698,7 @@ public class JSFVascEntrySupportBean implements Serializable {
logger.fine("deleteAction");
JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(event.getComponent());
VascEntry entry = comp.getVascEntry();
VascEntryState state = entry.getVascFrontendData().getVascEntryState();
VascEntryState state = entry.getVascFrontendController().getVascEntryState();
List<Object> sels = new ArrayList<Object>(5);
for (Integer rowId:state.getMultiActionSelection().keySet()) {
@ -711,18 +711,18 @@ public class JSFVascEntrySupportBean implements Serializable {
}
if (sels.isEmpty()==false) {
for (Object row:sels) {
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(row);
entry.getVascFrontendData().getVascFrontendActions().deleteObject();
entry.getVascFrontendController().getVascEntryState().setEntryDataObject(row);
entry.getVascFrontendController().getVascFrontendActions().deleteObject();
}
state.getMultiActionSelection().clear(); // after down deselect all options
} else {
entry.getVascFrontendData().getVascFrontendActions().deleteObject();
entry.getVascFrontendController().getVascFrontendActions().deleteObject();
}
try {
entry.getVascFrontendData().getVascFrontend().renderView();
entry.getVascFrontendController().getVascFrontend().renderView();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e);
}
}
@ -751,7 +751,7 @@ public class JSFVascEntrySupportBean implements Serializable {
try {
action.doGlobalAction(entry);
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e);
}
// restore normal view for next request.
@ -777,7 +777,7 @@ public class JSFVascEntrySupportBean implements Serializable {
ex.doExport(out, entry);
out.close();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e);
} finally {
fc.responseComplete();
}
@ -807,10 +807,10 @@ public class JSFVascEntrySupportBean implements Serializable {
//selectedDirectPage = "null";
try {
entry.getVascFrontendData().getVascFrontendActions().pageAction(new Integer(id));
entry.getVascFrontendData().getVascFrontend().renderView();
entry.getVascFrontendController().getVascFrontendActions().pageAction(new Integer(id));
entry.getVascFrontendController().getVascFrontend().renderView();
} catch (Exception e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e);
}
}
@ -999,7 +999,7 @@ class JSFVascSupportI18nMapController implements Map<String,String> {
}
public String get(Object key) {
String result = entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue((String)key);
String result = entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue((String)key);
return result;
}

View file

@ -30,7 +30,7 @@ import javax.faces.context.FacesContext;
import net.forwardfire.vasc.core.entry.VascEntryExporter;
import net.forwardfire.vasc.frontend.AbstractVascFrontend;
import net.forwardfire.vasc.frontend.VascFrontendData;
import net.forwardfire.vasc.frontend.VascFrontendController;
import net.forwardfire.vasc.frontend.web.jsf.ui.JSFBoolean;
import net.forwardfire.vasc.frontend.web.jsf.ui.JSFLabel;
import net.forwardfire.vasc.frontend.web.jsf.ui.JSFList;
@ -66,7 +66,7 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser
protected void addUiComponents() {
VascFrontendData vfd = getVascEntry().getVascFrontendData();
VascFrontendController vfd = getVascEntry().getVascFrontendController();
// required UI components
vfd.putVascUIComponent(net.forwardfire.vasc.core.ui.VascUIComponent.VASC_LABEL,JSFLabel.class.getName());
@ -100,12 +100,12 @@ public class JSFVascFrontendRenderer extends AbstractVascFrontend implements Ser
UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();
JSFVascUIComponent comp = JSFVascUIComponent.findVascChild(viewRoot,getVascEntry().getId());
comp.setRenderFacetState("editView");
entry.getVascFrontendData().getVascFrontendHelper().editReadOnlyUIComponents(entry);
entry.getVascFrontendController().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);
if (entry.getVascFrontendController().getVascEntryState().isEditCreate()) {
int index = entry.getVascFrontendController().getVascEntryState().getEntryDataList().size()+1;
selBean = new VascDataBackendBean(entry,entry.getVascFrontendController().getVascEntryState().getEntryDataObject(),index);
} else {
selBean = comp.getSupportBean().getSelectedTableRecord();
}

View file

@ -26,6 +26,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.logging.Logger;
import javax.el.ValueExpression;
@ -36,14 +37,14 @@ import javax.faces.context.FacesContext;
import net.forwardfire.vasc.core.VascController;
import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryField;
import net.forwardfire.vasc.core.VascEntryLocal;
import net.forwardfire.vasc.core.VascEntryState;
import net.forwardfire.vasc.core.VascException;
import net.forwardfire.vasc.core.VascLinkEntry;
import net.forwardfire.vasc.core.VascEntryLink;
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener;
import net.forwardfire.vasc.core.entry.VascEntryFrontendEventListener.VascFrontendEventType;
import net.forwardfire.vasc.frontend.VascFrontendData;
import net.forwardfire.vasc.frontend.VascFrontendController;
import net.forwardfire.vasc.frontend.web.jsf.ui.JSFListModel;
import net.forwardfire.vasc.impl.DefaultVascFactory;
/**
* Renders an JSF vasc entry views.
@ -56,9 +57,6 @@ import net.forwardfire.vasc.impl.DefaultVascFactory;
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";
@ -70,7 +68,7 @@ public class JSFVascUIComponent extends UIComponentBase {
private JSFVascFrontendRenderer renderer = null;
private JSFVascEntrySupportBean supportBean = null;
private String renderFacetState = null;
private VascLinkEntry link = null;
private VascEntryLink link = null;
private VascEntryState linkState = null;
private VascEntryState state = null;
private Object stateEditId = null;
@ -89,15 +87,12 @@ public class JSFVascUIComponent extends UIComponentBase {
@Override
public Object saveState(FacesContext facesContext) {
logger.fine("Save State");
Object values[] = new Object[8];
Object values[] = new Object[5];
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);
values[1] = renderer;
values[2] = supportBean;
values[3] = renderFacetState;
values[4] = this.getAttributes().get(INJECT_TABLE_OPTIONS_ON_CHANGE);
return values;
}
@ -107,13 +102,10 @@ public class JSFVascUIComponent extends UIComponentBase {
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];
renderer = (JSFVascFrontendRenderer) values[1];
supportBean = (JSFVascEntrySupportBean) values[2];
renderFacetState = (String) values[3];
injectTableOptionOnChange = (String) values[4];
// TODO: check if we can move this some day...
String entrySupportVar = (String)getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
@ -175,11 +167,11 @@ public class JSFVascUIComponent extends UIComponentBase {
return renderer.getVascEntry();
}
protected void initGoto(VascLinkEntry link) {
protected void initGoto(VascEntryLink link) {
logger.fine("init goto "+link);
this.link=link;
}
protected void initGoto(VascLinkEntry link,VascEntryState state) {
protected void initGoto(VascEntryLink link,VascEntryState state) {
logger.fine("init goto link: "+link);
this.link=link;
this.linkState=state;
@ -220,7 +212,7 @@ public class JSFVascUIComponent extends UIComponentBase {
}
supportBean = new JSFVascEntrySupportBean(entry);
// copy search string for preadded search string from application layer
supportBean.setSearchString(entry.getVascFrontendData().getVascEntryState().getVascBackendState().getSearchString());
supportBean.setSearchString(entry.getVascFrontendController().getVascEntryState().getVascBackendState().getSearchString());
init = true;
}
@ -237,10 +229,10 @@ public class JSFVascUIComponent extends UIComponentBase {
// edit action copyed
try {
VascEntry entry = supportBean.getVascEntry();
entry.getVascFrontendData().getVascEntryState().setEditCreate(false);
entry.getVascFrontendData().fireVascFrontendEvent(entry, VascFrontendEventType.SELECT, rowObject);
entry.getVascFrontendData().getVascEntryState().setEntryDataObject(rowObject);
entry.getVascFrontendData().getVascFrontend().renderEdit();
entry.getVascFrontendController().getVascEntryState().setEditCreate(false);
entry.getVascFrontendController().fireVascFrontendEvent(entry, VascFrontendEventType.SELECT, rowObject);
entry.getVascFrontendController().getVascEntryState().setEntryDataObject(rowObject);
entry.getVascFrontendController().getVascFrontend().renderEdit();
} catch (Exception e) {
throw new RuntimeException("Could not renderEdit: "+e.getMessage(),e);
}
@ -306,44 +298,34 @@ public class JSFVascUIComponent extends UIComponentBase {
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);
}
VascController vascController = (VascController)FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(VascRequestFacesFilter.REQ_VASC_CONTOLLER);
String entryId = (String)FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(VascRequestFacesFilter.REQ_VASC_ENTRY_ID);
if (link!=null) {
entryName = link.getVascEntryId();
entryId = link.getVascEntryId();
}
if (state!=null) {
entryName = state.getVascEntry().getId();
entryId = state.getVascEntry().getId();
}
VascEntry entry = vascController.getVascEntryController().getVascEntryById(entryName);
VascEntryLocal entry = (VascEntryLocal)vascController.getVascEntryController().getVascEntryById(entryId);
if (entry==null) {
throw new NullPointerException("Could not locate '"+entryName+"' from : "+vascController);
throw new NullPointerException("Could not get '"+entryId+"' from : "+vascController);
}
frontendData.setVascFrontend(null); // reset data obj. todo rm this.
try {
DefaultVascFactory.fillVascEntryFrontend(entry, vascController, frontendData);
frontendData.initFrontendListeners(entry,"jsf");
vascController.getVascEntryConfigController().configVascFrontendController(vascController, entry);
} catch (Exception e1) {
throw new RuntimeException(e1);
}
VascFrontendController frontendData = entry.getVascFrontendController();
try {
frontendData.initFrontendListeners(entry,"jsf");
} catch (Exception e1) {
e1.printStackTrace();
}
if (state!=null) {
// copy prevois parent
@ -353,7 +335,7 @@ public class JSFVascUIComponent extends UIComponentBase {
if (link!=null) {
// save state
if (linkState==null) {
frontendData.getVascEntryState().setParent(getVascEntry().getVascFrontendData().getVascEntryState());
frontendData.getVascEntryState().setParent(getVascEntry().getVascFrontendController().getVascEntryState());
} else {
frontendData.getVascEntryState().setParent(linkState);
}
@ -375,7 +357,7 @@ public class JSFVascUIComponent extends UIComponentBase {
Object selectedValue = v.getVascEntryFieldValue().getValue(v, selected);
// set data parameter on new vasc entry
entry.getVascFrontendData().getVascEntryState().getVascBackendState().setDataParameter(parameterName, selectedValue);
entry.getVascFrontendController().getVascEntryState().getVascBackendState().setDataParameter(parameterName, selectedValue);
logger.fine("Setting link parameter: "+parameterName+" with: "+selectedValue);
}
@ -388,7 +370,7 @@ public class JSFVascUIComponent extends UIComponentBase {
}
// create listener for new objects
entry.getVascFrontendData().addVascEntryFrontendEventListener(new CreateEntryFieldValuesListener2(fieldId,selectedValue));
entry.getVascFrontendController().addVascEntryFrontendEventListener(new CreateEntryFieldValuesListener2(fieldId,selectedValue));
}
} catch (Exception e) {
throw new RuntimeException("error: "+e.getMessage(),e);
@ -397,7 +379,7 @@ public class JSFVascUIComponent extends UIComponentBase {
String entrySupportVar = (String)getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
entry.getVascFrontendData().addVascEntryFrontendEventListener(new JSFVascEntryEventListener(entrySupportVar));
entry.getVascFrontendController().addVascEntryFrontendEventListener(new JSFVascEntryEventListener(entrySupportVar));
return entry;
}
@ -422,7 +404,7 @@ public class JSFVascUIComponent extends UIComponentBase {
try {
field.getVascEntryFieldValue().setValue(field, data, value);
} catch (VascException e) {
entry.getVascFrontendData().getVascFrontendHelper().handleException(entry, e);
entry.getVascFrontendController().getVascFrontendHelper().handleException(entry, e);
}
}
}

View file

@ -63,9 +63,10 @@ import javax.faces.validator.ValidatorException;
import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryField;
import net.forwardfire.vasc.core.VascEntryListOption;
import net.forwardfire.vasc.core.VascException;
import net.forwardfire.vasc.core.VascLinkEntry;
import net.forwardfire.vasc.core.VascLinkEntryType;
import net.forwardfire.vasc.core.VascEntryLink;
import net.forwardfire.vasc.core.VascEntryLinkType;
import net.forwardfire.vasc.core.actions.RowVascAction;
import net.forwardfire.vasc.core.ui.VascOptionValueModelListener;
import net.forwardfire.vasc.core.ui.VascUIComponent;
@ -106,7 +107,7 @@ public class JSFVascUIComponentRenderer extends Renderer {
// hack for edit back action to set field disabled
VascEntry entry = comp.getVascEntry();
entry.getVascFrontendData().getVascFrontendHelper().editReadOnlyUIComponents(entry);
entry.getVascFrontendController().getVascFrontendHelper().editReadOnlyUIComponents(entry);
}
// render the current facet of the vasc component
@ -160,7 +161,7 @@ public class JSFVascUIComponentRenderer extends Renderer {
}
private String i18n(VascEntry entry,String key,Object...params) {
return entry.getVascFrontendData().getVascEntryResourceResolver().getTextValue(key,params);
return entry.getVascFrontendController().getVascEntryResourceResolver().getTextValue(key,params);
}
@ -177,7 +178,7 @@ public class JSFVascUIComponentRenderer extends Renderer {
String entrySupportVar = (String)comp.getAttributes().get(JSFVascUIComponent.ENTRY_SUPPORT_VAR_KEY);
for (VascEntryField c:entry.getVascEntryFields()) {
if (entry.getVascFrontendData().getVascFrontendHelper().renderEdit(c)==false) {
if (entry.getVascFrontendController().getVascFrontendDataSelector().isFieldEdit(c)==false) {
continue;
}
for (int i=0;i<c.getVascEntryFieldType().getUIComponentCount(c);i++) {
@ -217,7 +218,7 @@ public class JSFVascUIComponentRenderer extends Renderer {
//column++;
// i==0 is for multi field editor support... which is still very in progress
if (i==0) {
entry.getVascFrontendData().addFieldVascUIComponents(c, editor,jsfEdit);
entry.getVascFrontendController().addFieldVascUIComponents(c, editor,jsfEdit);
}
}
}
@ -252,7 +253,7 @@ public class JSFVascUIComponentRenderer extends Renderer {
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);
List<String> errors = entry.getVascFrontendController().getVascFrontendHelper().validateObjectField(field);
logger.fine("Validate: "+component+" errors: "+errors.size()+" value: "+object);
if (errors.isEmpty()) {
return; // no errors
@ -283,7 +284,7 @@ public class JSFVascUIComponentRenderer extends Renderer {
//JSFVascUIComponent comp = JSFVascUIComponent.findVascParent(grid);
VascEntry entry = comp.getVascEntry();
for (VascEntryField option:entry.getListOptions()) {
for (VascEntryListOption option:entry.getVascEntryListOptions()) {
for (int i=0;i<option.getVascEntryFieldType().getUIComponentCount(option);i++) {
VascUIComponent label = option.getVascEntryFieldType().provideLabelUIComponent(i,option);
@ -342,11 +343,11 @@ public class JSFVascUIComponentRenderer extends Renderer {
}
// 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.getVascFrontendController().addFieldVascUIComponents(option, editor,jsfEdit);
}
}
}
entry.getVascFrontendData().getVascFrontendHelper().headerOptionsCreatedFillData(entry);
entry.getVascFrontendController().getVascFrontendHelper().headerOptionsCreatedFillData(entry);
}
public class ModelChangeListener implements ValueChangeListener,Serializable {
private static final long serialVersionUID = 1L;
@ -372,7 +373,7 @@ public class JSFVascUIComponentRenderer extends Renderer {
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()) {
if (!entry.getVascFrontendController().getVascFrontendHelper().getMultiRowActions(entry).isEmpty()) {
UIColumn colUp = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE);
colUp.setId(viewRoot.createUniqueId());
@ -397,7 +398,7 @@ public class JSFVascUIComponentRenderer extends Renderer {
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);
ValueExpression ve1 = application.getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(),"#{"+entrySupportVar+".vascEntry.vascFrontendController.vascEntryState.multiActionSelection["+tableRecordVar+".recordId]}",Object.class);
select.setValueExpression("value", ve1);
colUp.getChildren().add(select);
@ -406,7 +407,7 @@ public class JSFVascUIComponentRenderer extends Renderer {
for (VascEntryField c:entry.getVascEntryFields()) {
if (entry.getVascFrontendData().getVascFrontendHelper().renderList(c)==false) {
if (entry.getVascFrontendController().getVascFrontendDataSelector().isFieldList(c)==false) {
continue;
}
UIColumn col = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE);
@ -454,7 +455,7 @@ public class JSFVascUIComponentRenderer extends Renderer {
table.getChildren().add(col);
}
if (entry.getVascFrontendData().getVascEntryState().getVascBackend().isRecordMoveable()) {
if (entry.getVascFrontendController().getVascEntryState().getVascBackend().isRecordMoveable()) {
UIColumn colUp = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE);
colUp.setId(viewRoot.createUniqueId());
@ -493,7 +494,7 @@ public class JSFVascUIComponentRenderer extends Renderer {
table.getChildren().add(colDown);
}
for (VascLinkEntry vascLink:entry.getVascFrontendData().getVascFrontendHelper().getVascLinkEntryByType(entry, VascLinkEntryType.LIST)) {
for (VascEntryLink vascLink:entry.getVascFrontendController().getVascFrontendHelper().getVascLinkEntryByType(entry, VascEntryLinkType.LIST)) {
UIColumn col = (UIColumn)application.createComponent(UIColumn.COMPONENT_TYPE);
col.setId(viewRoot.createUniqueId());
@ -520,7 +521,7 @@ public class JSFVascUIComponentRenderer extends Renderer {
}
for (RowVascAction action:entry.getRowActions()) {
if (entry.getVascFrontendData().getVascFrontendHelper().renderRowVascAction(action)==false) {
if (entry.getVascFrontendController().getVascFrontendDataSelector().isActionAllowed(action)==false) {
continue;
}
if (AddRowAction.ACTION_ID.equals(action.getId())) {

View file

@ -38,9 +38,6 @@ 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;
@ -64,9 +61,7 @@ public class JSFVascUIComponentTag extends UIComponentELTag {
@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, 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);
@ -77,9 +72,6 @@ public class JSFVascUIComponentTag extends UIComponentELTag {
public void release() {
super.release();
vascController = null;
vascFrontendData = null;
entryName = null;
entrySupportVar = null;
tableRecordVar = null;
injectEditFieldsId = null;
@ -100,48 +92,6 @@ public class JSFVascUIComponentTag extends UIComponentELTag {
// ============= 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
*/

View file

@ -86,7 +86,7 @@ public class JSFVascValidatePhaseListener implements PhaseListener {
return; // no editing
}
VascEntry entry = comp.getVascEntry();
if (entry.getVascFrontendData().getVascEntryState().getEntryDataObject()==null) {
if (entry.getVascFrontendController().getVascEntryState().getEntryDataObject()==null) {
return; // we are not in edit mode.
}
UIInput in = (UIInput)component;

View file

@ -63,7 +63,7 @@ public class VascDataBackendBean implements Serializable {
if (index>entry.getVascEntryFields().size()) {
throw new IllegalArgumentException("Index is bigger then total field size: "+index);
}
return entry.getVascEntryFields().get(index);
return entry.getVascFrontendController().getVascFrontendDataSelector().getFieldsList().get(index);
}
static public int getIndexId(VascEntryField field) {

View file

@ -23,8 +23,6 @@
package net.forwardfire.vasc.frontend.web.jsf;
import java.io.IOException;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -45,6 +43,10 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.forwardfire.vasc.core.VascController;
import net.forwardfire.vasc.core.VascControllerProvider;
import net.forwardfire.vasc.core.VascEntry;
/**
* Parses the Request info path info 3 vasc attributes an dispatches the request to the templateFile.
*
@ -56,7 +58,11 @@ public class VascRequestFacesFilter implements Filter {
private Logger logger = null;
private String templateFile = null;
private ServletContext servletContext = null;
private String resourceBundle = null;
private VascController vascController = null;
private VascControllerProvider vascControllerProvider = null;
static public final String REQ_VASC_CONTOLLER = "requestScopeVascController";
static public final String REQ_VASC_ENTRY_ID = "requestScopeVascEntryId";
static public final String REQ_VASC_URI_PATH = "requestScopeVascUriPath";
/**
* @see javax.servlet.Filter#destroy()
@ -77,11 +83,30 @@ public class VascRequestFacesFilter implements Filter {
if (templateFile==null) {
throw new ServletException("No templateFile init-param found.");
}
resourceBundle=config.getInitParameter("resourceBundle");
if (resourceBundle==null) {
return; //throw new ServletException("No resourceBundle init-param found.");
String className = config.getInitParameter("vascControllerProvider");
if (className==null) {
throw new ServletException("Can't start with null vascControllerProvider init parameter.");
}
String classArgument = null;
int atIndex = className.indexOf('@');
if (atIndex > 0) {
classArgument = className.substring(0,atIndex);
className = className.substring(atIndex+1);
}
try {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if (cl == null) {
cl = className.getClass().getClassLoader();
}
Class<?> clazz = cl.loadClass(className);
if (classArgument==null) {
vascControllerProvider = (VascControllerProvider)clazz.newInstance();
} else {
vascControllerProvider = (VascControllerProvider)clazz.getConstructor(String.class).newInstance(classArgument);
}
} catch (Exception e) {
throw new ServletException("Could not create VascControllerProvider: "+e.getMessage(),e);
}
ResourceBundle.getBundle(resourceBundle); // test if it loads
}
@ -101,7 +126,7 @@ public class VascRequestFacesFilter implements Filter {
}
// stuff to fill
String entityName = null;
String entryId = null;
String actionName = null;
String actionRecordId = null;
@ -111,9 +136,9 @@ public class VascRequestFacesFilter implements Filter {
String actionString = null;
if (index>0) {
actionString = path.substring(index+1);
entityName = path.substring(0,index);
entryId = path.substring(0,index);
} else {
entityName = path;
entryId = path;
}
if (actionString!=null) {
@ -132,7 +157,7 @@ public class VascRequestFacesFilter implements Filter {
//log
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE,"entityName="+entityName+" actionName="+actionName+" actionRecordId="+actionRecordId);
logger.log(Level.FINE,"entryId="+entryId+" actionName="+actionName+" actionRecordId="+actionRecordId);
}
// Acquire the FacesContext instance for this request
@ -145,42 +170,34 @@ public class VascRequestFacesFilter implements Filter {
facesContext = facesContextFactory.getFacesContext(servletContext, request, response, lifecycle);
ProtectedFacesContext.setFacesContextAsCurrentInstance(facesContext);
UIViewRoot viewRoot = facesContext.getApplication().getViewHandler().createView(facesContext,entityName+actionName);
UIViewRoot viewRoot = facesContext.getApplication().getViewHandler().createView(facesContext,entryId+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 {
if (resourceBundle!=null) {
ResourceBundle i18n = ResourceBundle.getBundle(resourceBundle,locale);
String titleI18n = i18n.getString("vasc.entry."+entityName+".name");
request.setAttribute("requestScopeVascEntityNameI18n" ,titleI18n);
} else {
request.setAttribute("requestScopeVascEntityNameI18n" ,entityName);
if (vascController==null) {
synchronized (this) {
vascController = vascControllerProvider.getVascController();
}
} catch (Exception e) {
e.printStackTrace();
request.setAttribute("requestScopeVascEntityNameI18n" ,entityName);
}
// Fetch entry and do checks
VascEntry vascEntry = vascController.getVascEntryController().getVascEntryById(entryId);
if (vascEntry == null) {
response.sendRedirect("/");
return;
}
// add to request attributes
request.setAttribute(REQ_VASC_CONTOLLER, vascController);
request.setAttribute(REQ_VASC_ENTRY_ID, vascEntry.getId());
request.setAttribute(REQ_VASC_URI_PATH, request.getRequestURI());
// And dispatch to the vasc template file.
try {
request.getRequestDispatcher(templateFile).forward(request, response);
} catch (ViewExpiredException e) {
// lets try again
response.sendRedirect(request.getRequestURL().toString());
response.sendRedirect(request.getRequestURL().toString()); // lets try again
}
// done
}
private abstract static class ProtectedFacesContext extends FacesContext {

View file

@ -52,12 +52,11 @@ public class VascViewHandler extends ViewHandler {
*/
@Override
public String getActionURL(FacesContext context, String name) {
HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
if (request.getAttribute("requestScopeVascPath")==null) {
if (request.getAttribute(VascRequestFacesFilter.REQ_VASC_URI_PATH)==null) {
return parentViewHandler.getActionURL(context, name);
}
String path = (String)request.getAttribute("requestScopeVascPath");
String path = (String)request.getAttribute(VascRequestFacesFilter.REQ_VASC_URI_PATH);
return path;
}