dataview draft
This commit is contained in:
parent
db478a5b4e
commit
372c7887fb
3 changed files with 97 additions and 76 deletions
|
|
@ -26,20 +26,27 @@ package org.imixs.workflow.office.dataview;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.imixs.workflow.ItemCollection;
|
||||
import org.imixs.workflow.exceptions.AccessDeniedException;
|
||||
import org.imixs.workflow.engine.DocumentService;
|
||||
import org.imixs.workflow.exceptions.ModelException;
|
||||
import org.imixs.workflow.faces.data.AbstractDataController;
|
||||
import org.imixs.workflow.exceptions.QueryException;
|
||||
import org.imixs.workflow.faces.data.ViewController;
|
||||
import org.imixs.workflow.faces.data.ViewHandler;
|
||||
import org.imixs.workflow.office.forms.CustomFormController;
|
||||
import org.imixs.workflow.office.forms.CustomFormSection;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.enterprise.context.Conversation;
|
||||
import jakarta.enterprise.context.ConversationScoped;
|
||||
import jakarta.faces.context.FacesContext;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Named;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* The DataViewController is used to display a data view
|
||||
|
|
@ -47,29 +54,46 @@ import jakarta.inject.Named;
|
|||
* @author rsoika
|
||||
* @version 1.0
|
||||
*/
|
||||
// @Named
|
||||
// @ConversationScoped
|
||||
// public class DataViewController extends AbstractDataController {
|
||||
|
||||
@Named
|
||||
@ConversationScoped
|
||||
public class DataViewController extends AbstractDataController {
|
||||
// @ViewScoped
|
||||
public class DataViewController extends ViewController {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private List<CustomFormSection> sections;
|
||||
private String errorMessage;
|
||||
|
||||
@Inject
|
||||
private Conversation conversation;
|
||||
|
||||
@Inject
|
||||
private DocumentService documentService;
|
||||
|
||||
@Inject
|
||||
CustomFormController customFormController;
|
||||
|
||||
@Inject
|
||||
ViewHandler viewHandler;
|
||||
|
||||
protected ItemCollection data = null;
|
||||
private ItemCollection filter;
|
||||
private String query;
|
||||
|
||||
private static Logger logger = Logger.getLogger(DataViewController.class.getName());
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
||||
super.init();
|
||||
// this.setQuery(dataViewController.getQuery());
|
||||
this.setSortBy("$modified");
|
||||
this.setSortReverse(false);
|
||||
this.setPageSize(100);
|
||||
this.setLoadStubs(false);
|
||||
}
|
||||
|
||||
public ItemCollection getDefinition() {
|
||||
|
|
@ -83,11 +107,25 @@ public class DataViewController extends AbstractDataController {
|
|||
/**
|
||||
* This method loads the custom form sections
|
||||
*/
|
||||
@Override
|
||||
public void onLoad() {
|
||||
filter = new ItemCollection();
|
||||
super.onLoad();
|
||||
// super.onLoad();
|
||||
startConversation();
|
||||
|
||||
FacesContext facesContext = FacesContext.getCurrentInstance();
|
||||
if (!facesContext.isPostback() && !facesContext.isValidationFailed()) {
|
||||
// ...
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
Map<String, String> paramMap = fc.getExternalContext().getRequestParameterMap();
|
||||
// try to extract the uniqueid form the query string...
|
||||
String uniqueid = paramMap.get("id");
|
||||
if (uniqueid == null || uniqueid.isEmpty()) {
|
||||
// alternative 'workitem=...'
|
||||
uniqueid = paramMap.get("workitem");
|
||||
}
|
||||
data = documentService.load(uniqueid);
|
||||
}
|
||||
|
||||
try {
|
||||
// Init new Filter....
|
||||
if (data != null) {
|
||||
|
|
@ -125,12 +163,12 @@ public class DataViewController extends AbstractDataController {
|
|||
* elements with the values from the filter
|
||||
*
|
||||
*
|
||||
* @throws AccessDeniedException - if user has insufficient access rights.
|
||||
* @throws QueryException
|
||||
*/
|
||||
public void run() throws AccessDeniedException {
|
||||
|
||||
public void run() throws QueryException {
|
||||
reset();
|
||||
Date date = filter.getItemValueDate("date.from");
|
||||
logger.info(" date=" + date);
|
||||
logger.info("x date=" + date);
|
||||
|
||||
query = data.getItemValueString("query");
|
||||
|
||||
|
|
@ -156,6 +194,9 @@ public class DataViewController extends AbstractDataController {
|
|||
}
|
||||
logger.info("query=" + query);
|
||||
|
||||
// Prefetch data to update total count and page count
|
||||
viewHandler.getData(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -191,4 +232,17 @@ public class DataViewController extends AbstractDataController {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a new conversation
|
||||
*/
|
||||
protected void startConversation() {
|
||||
if (conversation.isTransient()) {
|
||||
conversation.setTimeout(
|
||||
((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest())
|
||||
.getSession().getMaxInactiveInterval() * 1000);
|
||||
conversation.begin();
|
||||
logger.log(Level.FINEST, "......start new conversation, id={0}", conversation.getId());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
package org.imixs.workflow.office.dataview;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.imixs.workflow.faces.data.ViewController;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.faces.view.ViewScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Named;
|
||||
|
||||
@Named
|
||||
@ViewScoped
|
||||
public class DataViewSearchController extends ViewController {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static Logger logger = Logger.getLogger(DataViewSearchController.class.getName());
|
||||
|
||||
@Inject
|
||||
DataViewController dataViewController;
|
||||
|
||||
@Override
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
super.init();
|
||||
this.setQuery(dataViewController.getQuery());
|
||||
this.setSortBy("$modified");
|
||||
this.setSortReverse(false);
|
||||
this.setPageSize(100);
|
||||
this.setLoadStubs(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQuery() {
|
||||
logger.fine("query: " + dataViewController.getQuery());
|
||||
return dataViewController.getQuery();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -13,13 +13,8 @@
|
|||
<ui:define name="content">
|
||||
|
||||
<f:view>
|
||||
<h:form id="textblock_form_id" pt:autocomplete="on">
|
||||
<h:form id="dataview_id" pt:autocomplete="on">
|
||||
|
||||
<ui:param name="searchresult" value="#{viewHandler.getData(dataViewSearchController)}"></ui:param>
|
||||
<ui:param name="searchresultCount" value="#{dataViewSearchController.getTotalCount()}"></ui:param>
|
||||
<ui:param name="searchPage"
|
||||
value="#{(dataViewSearchController.getPageIndex()+1)}/#{(dataViewSearchController.getTotalPages())}">
|
||||
</ui:param>
|
||||
|
||||
|
||||
<div class="imixs-form">
|
||||
|
|
@ -30,9 +25,9 @@
|
|||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="imixs-form-panel">
|
||||
<h:panelGroup styleClass="imixs-form-panel imixs-view" layout="block" id="dataview_form_id">
|
||||
|
||||
<div class="imixs-form-section">
|
||||
<div class=" imixs-form-section">
|
||||
|
||||
<ui:include src="/pages/workitems/forms/custom_sections.xhtml">
|
||||
<ui:param name="customFormSections" value="#{customFormController.sections}" />
|
||||
|
|
@ -42,19 +37,24 @@
|
|||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</h:panelGroup>
|
||||
|
||||
|
||||
|
||||
|
||||
<h:panelGroup styleClass="imixs-view imixs-search" layout="block" id="dataview_result_id">
|
||||
<ui:param name="searchResult" value="#{viewHandler.getData(dataViewController)}" />
|
||||
<ui:param name="searchPage"
|
||||
value="#{(dataViewController.getPageIndex()+1)}/#{(dataViewController.getTotalPages())}" />
|
||||
|
||||
|
||||
|
||||
<h:panelGroup styleClass="imixs-view imixs-search" layout="block" id="search_view">
|
||||
<!-- Buttons -->
|
||||
<div class="imixs-form-section">
|
||||
<div style="float:left;">
|
||||
<h:commandButton value="Anzeigen" action="#{dataViewController.run()}">
|
||||
<f:ajax render="@form" execute="@form" onevent="updateSearchForm" />
|
||||
<f:ajax execute="@form dataview_result_id" render="dataview_result_id"
|
||||
onevent="updateDataView" />
|
||||
</h:commandButton>
|
||||
|
||||
<h:commandButton value="Excel Export" action="#{dataViewController.run()}" />
|
||||
|
|
@ -63,6 +63,9 @@
|
|||
|
||||
<!-- Sort Order -->
|
||||
<div class="pull-right ">
|
||||
<span class="search-result-summary">#{message.total_result}
|
||||
#{dataViewController.getTotalCount()}
|
||||
#{message.serach_hits}</span>
|
||||
<div class=" ui-button ui-widget ui-state-default ui-corner-all"
|
||||
style="padding: 0 10px;">
|
||||
<h:outputText title="#{message['worklist.sortorder_help']}"
|
||||
|
|
@ -86,17 +89,16 @@
|
|||
</span>
|
||||
</div>
|
||||
|
||||
<h:commandButton actionListener="#{viewHandler.back(dataViewSearchController)}"
|
||||
style="height: 31px;" disabled="#{dataViewSearchController.pageIndex==0}"
|
||||
<h:commandButton actionListener="#{viewHandler.back(dataViewController)}"
|
||||
style="height: 31px;" disabled="#{dataViewController.pageIndex==0}"
|
||||
value="◀◀ #{message.prev}">
|
||||
<f:ajax render="search_view"
|
||||
onevent="function(data) { imixsOfficeMain.layoutAjaxEvent(data, '#{component.parent.parent.clientId}') }" />
|
||||
<f:ajax render="dataview_result_id" onevent="updateDataView" />
|
||||
</h:commandButton>
|
||||
<h:commandButton actionListener="#{viewHandler.forward(dataViewSearchController)}"
|
||||
style="height: 31px;" disabled="#{dataViewSearchController.endOfList}"
|
||||
<h:commandButton actionListener="#{viewHandler.forward(dataViewController)}"
|
||||
style="height: 31px;"
|
||||
disabled="#{dataViewController.endOfList or dataViewController.getTotalPages() le 1}"
|
||||
value="#{message.next} ▶▶">
|
||||
<f:ajax render="search_view"
|
||||
onevent="function(data) { imixsOfficeMain.layoutAjaxEvent(data, '#{component.parent.parent.clientId}') }" />
|
||||
<f:ajax render="dataview_result_id" onevent="updateDataView" />
|
||||
</h:commandButton>
|
||||
|
||||
|
||||
|
|
@ -106,9 +108,7 @@
|
|||
<div class="imixs-form-section">
|
||||
|
||||
|
||||
<div class="search-result-summary">#{message.total_result} #{searchresultCount}
|
||||
#{message.serach_hits}</div>
|
||||
<h:dataTable id="view_body" styleClass="imixsdatatable" value="#{searchresult}"
|
||||
<h:dataTable id="view_body" styleClass="imixsdatatable" value="#{searchResult}"
|
||||
var="record">
|
||||
|
||||
<h:column>
|
||||
|
|
@ -148,6 +148,12 @@
|
|||
|
||||
});
|
||||
|
||||
//ajax refresh...
|
||||
function updateDataView(data, context) {
|
||||
if (data.status === 'success') {
|
||||
imixsOfficeMain.layoutAjaxEvent(data);
|
||||
}
|
||||
}
|
||||
|
||||
/*]]>*/
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue