<dif:column attribute="<%=Atividade.Fields.DOCUMENTID%>" type="<%=Column.TYPE_DOCUMENT_EDITOR%>"
title="${messages.atividadeDocumento}"/>
<dif:document templateID="diftemplate2Col" ajaxRequestsTimeout="60000">
this.getDocumentTag().setAjaxRequestsTimeout(120000);
this.context.redirectTo(this.context.getStage(), "pedidoID=" + this.pedido.getId(), true);
this.context.getRequest().addParameter("newTipoID", null);
this.context.setPreventPreviousSubmitOnRedirection();
Componente ListPicker
Foi criado um novo componente para situações em que o objetivo é apenas mostrar um Dialog com uma Grid dentro para escolha de um registo.
Não precisa de nenhum código Java side, só JSP e tem várias variantes de apresentação através dos seus parâmetros:
<dif:listPicker id="selectTipo" title="${messages.selectNovoTipoPedido}"
dataSetBeanClass="<%=TipoPedidoCreditacao.class%>"
descriptionColumnAttribute="<%=TipoPedidoCreditacao.Fields.NOME%>"
descriptionDetailsColumnAttribute="<%=TipoPedidoCreditacao.Fields.DESCRICAO%>"
width="500" height="350" idColumnVisible="false"
selectElementType="<%=SelectElementType.ACTION_LINK%>"
destinationStageID="<%=EdicaoPedidoCreditacaoUC.class.getSimpleName()%>"
destinationStageParameters="pedidoID=${stage.pedido.id}&newTipoID=$[id]"/>
Combo Boxes para tabelas sem filtros sem necessidade de OnAjax na stage
A mesma sintaxe do ListPicker foi adicionada à ComboBox:
<dif:comboField id="<%="item"+PedidoCredItem.FK().tipoPedidoCredItem().ID()%>" autocomplete="false"
dataSourceAttribute="<%=PedidoCredItem.FK().tipoPedidoCredItem().ID()%>" width="580"
dataSetBeanClass="<%=TipoPedidoCredItem.class%>"
dataSetDescriptionField="<%=TipoPedidoCredItem.Fields.NOME%>"
dataSetDescriptionDetailField="<%=TipoPedidoCredItem.Fields.DESCRICAO%>"
dataSetOrderByField="<%=TipoPedidoCredItem.Fields.DESCRICAO%>"/>
ORM: Várias melhorias introduzidas com o novo ORM
Algumas ainda a meio mas várias já operacionais:
Obtenção de um DataSet sem passar pela sessão ou factory:
Event.getDataSetInstance().query().asList();
Obtenção de um objeto pelo seu ID mesmo que composto:
Event event = Event.getInstance(1L);
Obtenção de proxy objects (não fazem o select à BD (são lazy loaded) úteis para criação de registos e setar as suas dependências:
PedidoCreditacao pedido = new PedidoCreditacao();
pedido.setDataPedido(new Timestamp(new Date().getTime()));
pedido.setIndividuo(Individuo.getProxy(Long.valueOf(this.getUserPreferences().getCodeIndividuo())));
pedido.setTipoPedidoCreditacao(TipoPedidoCreditacao.getProxy(this.newRecordTipoID));
pedido.setEstadoPedidoCreditacao(EstadosPedidoCreditacaoUC.CRIADO);
pedido = PedidoCreditacao.getDataSetInstance().insert(pedido);
Definição dos campos de um JSONResponseDataSetGrid:
(todos os campos da tabela principal adicionados de 4 campos de relações)
response = new JSONResponseDataSetGrid<PedidoCredItem>(PedidoCredItem.getDataSetInstance());
response.setFields(PedidoCredItem.Fields.values());
response.addField(PedidoCredItem.FK().tipoPedidoCredItem().ID());
response.addField(PedidoCredItem.FK().tipoPedidoCredItem().NOME());
response.addField(PedidoCredItem.FK().estadoPedidoCredItem().ID());
response.addField(PedidoCredItem.FK().estadoPedidoCredItem().DESCRICAO());
<dif:grid id="pedidoItemsGrid" ajaxEvent="pedidoItems" showBorder="false" showResetConfigButton="false"
delRow="true" readonly="${!stage.canEdit}" noDataMessage="${messages.pedidoSemItems}"
groupColumn="<%=PedidoCredItem.FK().tipoPedidoCredItem().NOME()%>"
onWrite="obterCalculoValorfunc({updateTotal:true,showCalculos:false});">
<dif:summaryItem title="${messages.idTipo}" value="${stage.pedido.tipoPedidoCreditacao.nome}"
actionLabel="${messages.mudarTipo}" actionJS="funcselectTipo()"/>
<dif:summaryItem title="${messages.idEstado}" value="${stage.pedido.estadoPedidoCreditacao.descricao}"
newLine="true" highlight="true"/>
Para já é só... :-D
Tudo isto está no Development da DIF e em uso no Development do SigesSrv.
Obrigado.
<dif:listPicker id="selectTipo" title="${messages.selectNovoTipoPedido}"
dataSetBeanClass="<%=TipoPedidoCreditacao.class%>"
descriptionColumnAttribute="<%=TipoPedidoCreditacao.Fields.NOME%>"
descriptionDetailsColumnAttribute="<%=TipoPedidoCreditacao.Fields.DESCRICAO%>"
width="600" height="350" idColumnVisible="false"
selectElementType="<%=SelectElementType.ACTION_LINK%>"
destinationStageID="<%=EdicaoPedidoCreditacaoUC.class.getSimpleName()%>"
destinationStageParameters="pedidoID=${stage.pedido.id}&newTipoID=$[id]">
<dif:additionalColumn attribute="<%=TipoPedidoCreditacao.Fields.VALOR%>"
dataType="<%=ColumnDataType.MONEY_EURO%>" width="100px"/>
</dif:listPicker>
// Description calcField
response.addCalculatedField("desc",
new TitleDescriptionCalcField(FileBundleFile.Fields.TITLE, FileBundleFile.Fields.DESCRIPTION,
true));
<dif:summaryRightContentArea>
<dif:documentGenerator documentID="${stage.pedido.idDocComprovativo}" description=""
layout="<%=Download.RIGHT_BOX_LAYOUT%>"/>
</dif:summaryRightContentArea>
<dif:column attribute="<%=FileType.Fields.MAXFILESIZE%>" width="80px" suffix="Kb"/>
response.addDefaultValueForNewRecords(FileBundleFile.FK().fileBundle().ID(), this.fileBundleID);
@OnAJAX("fileBundles")
public IJSONRawResponse getFileBundles() throws DataSetException
{
JSONResponseDataSetGrid<FileBundle> response =
new JSONResponseDataSetGrid<FileBundle>(FileBundle.getDataSetInstance());
response.setHandleRESTActions(true, true, true, true, null);
response.setAfterInsertTrigger(new IJSONResponseAfterRecordChangeTrigger<FileBundle>()
{
@Override
public void doAfterAction(FileBundle record)
{
FileBundleEditor.allowEditFileBundleID(FileBundlesExplorer.this.context.getSession(), record.getId());
}
});
return response;
}
// Defined the calc field
this.getGridTag().addCalcField(this.getAttribute() + "Calc",
new FileBundleEditorCalcField(this.getDIFSession(), this.getAttribute(), this.getRefreshFunction(),
this.getLanguage(), this.allowNewBundle, this.allowChangeToAnotherBundle, this.twoLineLayout,
updateCode.toString()));
<dif:dialog id="windowFiles" title="${messages.editBundleFiles}" panelContainer="true" width="900" height="700"
cleanLayout="true">
<dif:titlePanel><span id="bundleSummary"></span>
<dif:subTitlePanel actionID="bundleSummarySubTitleAction" actionLabel="toReplace"
actionJS="changeBundleState();">
<span id="bundleSummarySubTitle"></span></dif:subTitlePanel>
</dif:titlePanel>
<dif:grid id="gridFiles" ajaxEvent="files" showRowLines="false" showHeader="false" showStripeRows=“false”...
public boolean canInvalidate(FileBundleInstanceFile fileInstance)
{
// TODO: Viegas: WIP: Workflow: Tratar das ACLs
FileBundleFile fileBundleFile =
HibernateUtil.getOrLazyLoad(fileInstance.getFileBundleFile(), FileBundleFile.class);
FileBundleInstance fileBundleInstance =
HibernateUtil.getOrLazyLoad(fileInstance.getFileBundleInstance(), FileBundleInstance.class);
return !fileInstance.isIsInvalid() && fileInstance.getDocumentId() != null &&
fileBundleFile.isHasValidation() && fileBundleInstance.isIsOpen();
}
JSONResponseDataSetGrid<GenericBeanAttributes> response;
response = new JSONResponseDataSetGrid<GenericBeanAttributes>(...);
response.addCalculatedField("encryptedParamName", new EncryptDataCalcField("field1", "field2"));
JSONObject infoReceived = EncryptDataCalcField.decode(this.encryptedParamName);
this.field1 = infoReceived.getString("field1");
this.field2 = infoReceived.getString("field2");
public class FileBundleEditor extends AbstractComponentBuildOnStage
{
@Override protected StageToCall buildDefinition()
{
StageToCall stageToCall = new StageToCall(FILE_BUNDLE_EDITOR_STAGE_ID)
.addParameterIfNotNull("businessProcessTypeID", this.businessProcessTypeID)
.addParameterIfNotNull("fileBundleID", this.fileBundleID)
.addParameterIfNotNull("refreshFunction", this.refreshFunction)
.addParameterIfNotNull("businessProcessTypeID", this.businessProcessTypeID);
if (this.getFileBundleID() != null)
{
stageToCall.addParameterIfNotNull("singleBundleEditor", true);
allowEditFileBundleID(this.getDIFSession(), this.getFileBundleID());
}
return stageToCall;
}
@Override protected void customDoEndTag()
throws JspException, ConfigurationException, IdentityManagerException, UnsupportedEncodingException
{
ConfigurationPanel configurationPanel = this.findAncestorWithClass(ConfigurationPanel.class);
// On configuration panels in popup mode we won't render this component.
// It would not be called in most cases, and the panel binding bellow would have to be synced
// to the window rendering and not ON_LOAD time
if (configurationPanel == null || !configurationPanel.isPopupMode())
{
super.customDoEndTag();
if (this.getFileBundleID() != null)
{
IPanelContainer parentPanelContainer = this.findAncestorWithClass(IPanelContainer.class);
if (parentPanelContainer != null)
{
AbstractDIFTag parentPanelContainerTag = (AbstractDIFTag) parentPanelContainer;
String parentID = parentPanelContainerTag.getId();
StringBuilder b = new StringBuilder();
b.append("Ext.getCmp('" + parentID + "').setLayout(new Ext.layout.BorderLayout());\n");
b.append("Ext.getCmp('" + parentID + "').add(Ext.getCmp('gridFiles" + this.getFileBundleID() +
"'));");
this.getContributions().addContribution(
new JavaScriptDocumentContribution(ScriptletScope.ON_LOAD, b.toString()).setOrder(2000));
}
}
}
}
SessionPersistentStageStorageArea storageArea = context.getSessionPersistentStageStorageArea();
storageArea.put("var1", objectInstance);
String sql = "SELECT ... FROM ...";
SQLDataSet ds = new SQLDataSet(this.siges.getSession(), sql, SQLDialect.ORACLE, true);
return Option.listToOptions(ds.query().asList(), TableFormaConhecInst.Fields.ID,
TableFormaConhecInst.Fields.DESCRICAO);
/**
* The interface Business cache.
*/
public interface IBusinessCache
{
/** Clear cache. */
public void clearCache();
/** Gets app name. */
public String getAppName();
/** Gets cache date. */
public Date getCacheDate();
/** Gets cache description. */
public String getCacheDescription();
/** Gets cache name. */
public String getCacheName();
/** Gets expiration time. */
public long getExpirationTime();
}
this.projetoMontanteTotal = projeto.getVlMontanteTotal();
if (projeto.getTableProjSituacao() != null)
{
TableProjSituacao situacaoProjeto = projeto.getTableProjSituacao();
this.projetoIdSituacao = situacaoProjeto.getId();
}
if (projeto.getTableProjSitCand() != null)
{
TableProjSitCand situacaoCand = projeto.getTableProjSitCand();
this.projetoIdSitCand = situacaoCand.getId();
}
this.projetoMontanteTotal = projeto.getVlMontanteTotal();
this.projetoIdSituacao = projeto.getTableProjSituacaoId();
this.projetoIdSitCand = projeto.getTableProjSitCandId();
projeto.setVlMontanteTotal(this.projetoMontanteTotal);
if (this.projetoIdSituacao != null)
{
TableProjSituacao situacaoProjeto =
this.siges.getWEB_PROJETO().getTableProjSituacaoDataSet().get(this.projetoIdSituacao.toString());
projeto.setTableProjSituacao(situacaoProjeto);
}
if (this.projetoIdSitCand != null)
{
TableProjSitCand situacaoCand =
this.siges.getWEB_PROJETO().getTableProjSitCandDataSet().get(this.projetoIdSitCand.toString());
projeto.setTableProjSitCand(situacaoCand);
}
projeto.setVlMontanteTotal(this.projetoMontanteTotal);
projeto.setTableProjSituacaoProxyFromId(this.projetoIdSituacao);
projeto.setTableProjSitCandProxyFromId(this.projetoIdSitCand);