I have a project using DynamicJasper to create reports. It works fine so far, but when I wanted to add a chart to a previously functional report I run into issues.
I keep getting this:
net.sf.jasperreports.engine.design.JRValidationException: Report design not valid :
1. Field not found : customExpression_for_Ganancia
at net.sf.jasperreports.engine.design.JRAbstractCompiler.verifyDesign(JRAbstractCompiler.java:258)
at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:140)
at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:215)
at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperReport(DynamicJasperHelper.java:519)
at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperPrint(DynamicJasperHelper.java:279)
at ar.com.fdvs.dj.core.DynamicJasperHelper.generateJasperPrint(DynamicJasperHelper.java:232)
Ganancia being the only column in the chart that is a CustomExpression. If I don't add this column as a series to the chart, the chart renders properly. It seems the chart doesn't play well with expressions...
A snippet from my code:
private DynamicReport buildSalesReport() throws ColumnBuilderException, ClassNotFoundException, ChartBuilderException {
DynamicReportBuilder drb = new DynamicReportBuilder();
drb.setReportName("Reporte de Ventas")
.setTitle("Reporte de ventas")
.setSubtitle("Este reporte fue generado el " + new Date())
.setPrintColumnNames(false)
.setIgnorePagination(true)
.setMargins(10, 10, 10, 10)
.setUseFullPageWidth(true);
Style groupOneStyle = new Style();
groupOneStyle.setFont(Font.ARIAL_BIG);
groupOneStyle.setHorizontalAlign(HorizontalAlign.LEFT);
groupOneStyle.setVerticalAlign(VerticalAlign.MIDDLE);
AbstractColumn columnDisplayName = ColumnBuilder.getNew()
.setColumnProperty("bookingType.displayName", String.class.getName())
.setTitle("Tipo").setWidth(new Integer(40))
.setStyle(groupOneStyle)
.build();
AbstractColumn columnDestiny = ColumnBuilder.getNew()
.setColumnProperty("bookedObject.destiny", String.class.getName())
.setTitle("Destino").setWidth(new Integer(40))
.build();
Style priceStyle = new Style();
priceStyle.setHorizontalAlign(HorizontalAlign.RIGHT);
AbstractColumn columnCurrency = ColumnBuilder.getNew()
.setColumnProperty("bookedObject.currency.displayName", String.class.getName())
.setTitle("Cotizacion").setWidth(new Integer(5))
.setShowText(false)
.build();
Style footerStyle = new Style();
footerStyle.setFont(Font.ARIAL_MEDIUM);
footerStyle.setBorderTop(Border.THIN);
footerStyle.setHorizontalAlign(HorizontalAlign.RIGHT);
footerStyle.setVerticalAlign(VerticalAlign.MIDDLE);
AbstractColumn columnPrice = ColumnBuilder.getNew()
.setColumnProperty("bookedObject.price", Double.class.getName())
.setStyle(priceStyle)
.setPattern("$ 0.00")
.setTitle("Precio").setWidth(new Integer(25))
.build();
AbstractColumn columnCount = ColumnBuilder.getNew()
.setColumnProperty("count", Integer.class.getName())
.setStyle(priceStyle)
.setTitle("Cantidad").setWidth(new Integer(25))
.build();
columnCount.setName("Cantidad");
AbstractColumn columnProfit = ColumnBuilder.getNew()
.setCustomExpression(this.getProfitExpression())
.setStyle(priceStyle)
.setTitle("Ganancia").setWidth(new Integer(20))
.setPattern("$ 0.00")
.build();
columnProfit.setName("Ganancia");
GroupBuilder groupBookingTypeBuilder = new GroupBuilder();
DJGroup groupBookingType =
groupBookingTypeBuilder.setCriteriaColumn((PropertyColumn) columnDisplayName)
.setGroupLayout(GroupLayout.VALUE_IN_HEADER_WITH_HEADERS_AND_COLUMN_NAME)
.build();
GroupBuilder groupCurrencyBuilder = new GroupBuilder();
DJGroup groupCurrency =
groupCurrencyBuilder.setCriteriaColumn((PropertyColumn) columnCurrency)
.addFooterVariable(columnCount,DJCalculation.SUM,footerStyle)
.addFooterVariable(columnProfit,DJCalculation.SUM,footerStyle)
.setGroupLayout(GroupLayout.VALUE_IN_HEADER)
.build();
drb.addColumn(columnDisplayName)
.addColumn(columnCurrency)
.addColumn(columnDestiny)
.addColumn(columnCount)
.addColumn(columnPrice)
.addColumn(columnProfit)
.addGroup(groupBookingType)
.addGroup(groupCurrency)
.setPrintBackgroundOnOddRows(true);
DJAxisFormat categoryAxisFormat = new DJAxisFormat("Destino");
categoryAxisFormat.setLabelFont(Font.ARIAL_SMALL);
categoryAxisFormat.setLabelColor(Color.DARK_GRAY);
categoryAxisFormat.setTickLabelFont(Font.ARIAL_SMALL);
categoryAxisFormat.setTickLabelColor(Color.DARK_GRAY);
categoryAxisFormat.setTickLabelMask("");
categoryAxisFormat.setLineColor(Color.DARK_GRAY);
DJAxisFormat valueAxisFormat = new DJAxisFormat("Ventas / Ingresos");
valueAxisFormat.setLabelFont(Font.ARIAL_SMALL);
valueAxisFormat.setLabelColor(Color.DARK_GRAY);
valueAxisFormat.setTickLabelFont(Font.ARIAL_SMALL);
valueAxisFormat.setTickLabelColor(Color.DARK_GRAY);
valueAxisFormat.setTickLabelMask("#,##0");
valueAxisFormat.setLineColor(Color.DARK_GRAY);
DJChart djChart = new DJBarChartBuilder()
//chart
.setX(20)
.setY(10)
.setWidth(500)
.setHeight(250)
.setCentered(false)
.setBackColor(Color.LIGHT_GRAY)
.setShowLegend(true)
.setPosition(DJChartOptions.POSITION_FOOTER)
.setTitle(new StringExpression() {
#Override
public Object evaluate(Map fields, Map variables, Map parameters) {
return variables.get("bookingType.displayName");
}
})
.setTitleColor(Color.DARK_GRAY)
.setTitleFont(Font.ARIAL_BIG_BOLD)
.setSubtitle("subtitle")
.setSubtitleColor(Color.DARK_GRAY)
.setSubtitleFont(Font.COURIER_NEW_BIG_BOLD)
.setLegendColor(Color.DARK_GRAY)
.setLegendFont(Font.COURIER_NEW_MEDIUM_BOLD)
.setLegendBackgroundColor(Color.WHITE)
.setLegendPosition(DJChartOptions.EDGE_BOTTOM)
.setTitlePosition(DJChartOptions.EDGE_TOP)
.setLineStyle(DJChartOptions.LINE_STYLE_DOTTED)
.setLineWidth(1)
.setLineColor(Color.DARK_GRAY)
.setPadding(5)
//dataset
.setCategory((PropertyColumn) columnDestiny)
.addSerie(columnCount, "Cantidad")
.addSerie(columnProfit, "Ganancia") // IF I COMMENT THIS LINE THE CHART IS RENDERED
//plot
.setCategoryAxisFormat(categoryAxisFormat)
.setValueAxisFormat(valueAxisFormat)
.build();
drb.addChart(djChart);
HashMap vars = new HashMap();
vars.put(columnCount, new JRDesignVariable());
vars.put(columnProfit, new JRDesignVariable());
JRDesignGroup group = new JRDesignGroup();
djChart.transform(new DynamicJasperDesign(), "", group, group, vars, 0);
DynamicReport dr = drb.build();
return dr;
}
public JasperPrint getJasperPrint(String status, String userOwner,
String hourFrom, String hourTo, String dateFrom, String dateTo)
throws ColumnBuilderException, ClassNotFoundException, JRException, ChartBuilderException {
DynamicReport dr = this.buildSalesReport();
JRDataSource ds = new JRBeanCollectionDataSource(
this.bookService.getReportBooks(status, userOwner, hourFrom, hourTo, dateFrom, dateTo));
return DynamicJasperHelper.generateJasperPrint(dr , new ClassicLayoutManager(), ds);
}
/**
*
* #return
*/
#SuppressWarnings("serial")
private CustomExpression getProfitExpression() {
return new CustomExpression() {
#SuppressWarnings("rawtypes")
#Override
public Object evaluate(Map fields, Map variables, Map parameters) {
Double amount = (Integer)fields.get("count") * (Double)fields.get("bookedObject.price");
return amount;
}
#Override
public String getClassName() {
return Double.class.getName();
}
};
As I said, the report is shown properly without the chart, with the chart, it fails only if the expression column is included as a series.
Any ideas are welcomed!
Just pushed the change for DJ 4.0.1 in commit 05243a3
Sometime today will also push for DJ 3.X
I've solved this very same problem doing the following:
Set the "fieldDescription" of your column.
Re-write the Method "protected Map registerChartVariable(ar.com.fdvs.dj.domain.chart.DJChart chart)" of class AbstractLayoutManager":
JRDesignExpression expression = new JRDesignExpression();
String property = ((PropertyColumn) col).getFieldDescription();
// ((PropertyColumn) col).getColumnProperty().getProperty();
expression.setText("$F{" + property + "}");
expression.setValueClass(clazz);
3 . As you have already figured out, you'll have to create your own LayoutManager for this task.
4 . This may not be the best solution, it is just an example how to fill the gap of DynamicJasper.
I ran into the same problem, but I had a slightly different solution. There are different types of Column classes, but only the PropertyColumn class is supported in the AbstractLayoutManager for charts. I found out that when you use a CustomExpression, the underlying Column class that is used is an ExpressionColumn. So, I modified the "protected Map registerChartVariable() method in the ar.com.fdvs.dj.core.layout.AbstractLayoutManager to support ExpressionColumn.
I changed the following 3 lines of code in that method:
JRDesignExpression expression = new JRDesignExpression();
expression.setText("$F{" + ((PropertyColumn) col).getColumnProperty().getProperty() + "}");
expression.setValueClass(clazz);
To the following:
if (col instanceof ExpressionColumn) {
ExpressionColumn expCol = (ExpressionColumn) col;
expression.setText(expCol.getTextForExpression());
expression.setValueClassName(expCol.getExpression().getClassName());
} else {
expression.setText("$F{" + ((PropertyColumn) col).getColumnProperty().getProperty() + "}");
expression.setValueClass(clazz);
}
This resolved the problem for me and I no longer get the "Field not found" message.
Related
I am new to DynamoDB and working on a dynamo project. I am trying to update the item amount in a transaction with condition if_not_exists() with TransactionWriteRequest in DynamoDB Mapper.
As per the Doc, transactionWriteRequest.updateItem() takes DynamoDBTransactionWriteExpression which doesn't have any UpdateExpression. Class definition is attached bellow.,
Wanted to know How can i provide the if_not_exists() in DynamoDBTransactionWriteExpression to update the item in a transaction. Or there is no way to do this in a transactionWrite.
Please help here.
Thanks in advance
Judging from the snippet you shared it seems you are using Java SDK v1. Below is a code snippet which has 1 PutItem and 1 UpdateItem combined in a single TransactWrite request.
AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().build();
final String ORDER_TABLE_NAME = "test1";
/*
Update Item with condition
*/
HashMap<String,AttributeValue> myPk =
new HashMap<String,AttributeValue>();
myPk.put("pk", new AttributeValue("pkValue1"));
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
expressionAttributeValues.put(":new_status", new AttributeValue("SOLD"));
Update markItemSold = new Update()
.withTableName(ORDER_TABLE_NAME)
.withKey(myPk)
.withUpdateExpression("SET ProductStatus = if_not_exists(createdAt, :new_status)")
.withExpressionAttributeValues(expressionAttributeValues)
.withReturnValuesOnConditionCheckFailure(ReturnValuesOnConditionCheckFailure.ALL_OLD);
/*
Put Item
*/
HashMap<String, AttributeValue> orderItem = new HashMap<>();
orderItem.put("pk", new AttributeValue("pkValue2"));
orderItem.put("OrderTotal", new AttributeValue("100"));
Put createOrder = new Put()
.withTableName(ORDER_TABLE_NAME)
.withItem(orderItem)
.withReturnValuesOnConditionCheckFailure(ReturnValuesOnConditionCheckFailure.ALL_OLD);
/*
Transaction
*/
Collection<TransactWriteItem> actions = Arrays.asList(
new TransactWriteItem().withUpdate(markItemSold),
new TransactWriteItem().withPut(createOrder));
TransactWriteItemsRequest placeOrderTransaction = new TransactWriteItemsRequest()
.withTransactItems(actions)
.withReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL);
try {
client.transactWriteItems(placeOrderTransaction);
System.out.println("Transaction Successful");
} catch (ResourceNotFoundException rnf) {
System.err.println("One of the table involved in the transaction is not found" + rnf.getMessage());
} catch (InternalServerErrorException ise) {
System.err.println("Internal Server Error" + ise.getMessage());
} catch (TransactionCanceledException tce) {
System.out.println("Transaction Canceled " + tce.getMessage());
} catch (AmazonServiceException e){
System.out.println(e.getMessage());
}
With the v2 version of the SDK you can do it like this
var table =
enhancedClient.table(<table name>, TableSchema.fromClass(DynamoEntity.class));
var transactWriteItemsEnhancedRequest = TransactWriteItemsEnhancedRequest
.builder()
.addUpdateItem(table,
TransactUpdateItemEnhancedRequest.builder(LoadTestEntity.class)
.item(<entity>)
.conditionExpression(Expression.builder().expression("attribute_not_exists(ID)").build())
.build())
.build();
enhancedClient.transactWriteItems(transactWriteItemsEnhancedRequest);
You might need to play around with the expression builder, I haven't tested it.
I've been trying different ways to populate components field while creating JIRA using JiraRestClient in java and somehow not able to do that.
Following is one of the approaches I tried -
public String createIssue(String projectKey, Long issueType, String issueSummary, String description) throws URISyntaxException {
IssueRestClient issueClient = restClient.getIssueClient();
ComponentRestClient componentClient = restClient.getComponentClient();
String componentUrl = "https://jira.abc.com/issues/?jql=project+%3D+PROJECTKEY+AND+component+%3D+%22Comp+Name%22";
Component component = componentClient.getComponent(new URI(componentUrl.trim())).claim();
//BasicComponent bc = new BasicComponent();
IssueInput newIssue = new IssueInputBuilder(projectKey, issueType, issueSummary)
.setDescription(description).setComponents(component).build();
return issueClient.createIssue(newIssue).claim().getKey();
}
With this I get error while JSON parsing step -
at org.codehaus.jettison.json.JSONTokener.syntaxError(JSONTokener.java:439) ~[jettison-1.1.jar:1.1]
at org.codehaus.jettison.json.JSONObject.<init>(JSONObject.java:169) ~[jettison-1.1.jar:1.1]
at org.codehaus.jettison.json.JSONObject.<init>(JSONObject.java:266) ~[jettison-1.1.jar:1.1]
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$1.handle(AbstractAsynchronousRestClient.java:147) ~[jira-rest-java-client-core-4.0.0.jar:?]
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$3.apply(AbstractAsynchronousRestClient.java:189) ~[jira-rest-java-client-core-4.0.0.jar:?]
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$3.apply(AbstractAsynchronousRestClient.java:185) ~[jira-rest-java-client-core-4.0.0.jar:?]
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:81) ~[atlassian-httpclient-api-0.23.0.jar:?]
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:11) ~[atlassian-httpclient-api-0.23.0.jar:?]
at com.atlassian.util.concurrent.Promises$Of$3.apply(Promises.java:268) ~[atlassian-util-concurrent-2.4.2.jar:?]
at com.atlassian.util.concurrent.Promises$2.onSuccess(Promises.java:158) ~[atlassian-util-concurrent-2.4.2.jar:?]
at com.google.common.util.concurrent.Futures$4.run(Futures.java:1132) ~[guava-20.0.jar:?]
at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:435) ~[guava-20.0.jar:?]
at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:900) ~[guava-20.0.jar:?]
Any help or suggestions will be highly appreciated!
This should work:
IssueInputBuilder builder = new IssueInputBuilder( projectKey, issueType, issueSummary );
Iterable<BasicComponent> components = restClient
.getProject( projectKey )
.getComponents( );
for ( BasicComponent c : components ) {
if ( c.getName().equals( "your component name" ) ) {
builder.setComponents( c ); // assuming you want only one component
}
}
IssueInput newIssue = builder.setDescription(description).build(); // etc...
I'm trying to add a formula tab and also trying to create a conditional
logic on that formula tab. What are the class name for formula tab and
create rule class (to invoke these)?
No idea which class invoke these methods.
package com.docusign.controller.examples;
import com.docusign.esign.api.TemplatesApi;
import com.docusign.esign.client.ApiClient;
import com.docusign.esign.client.ApiException;
import com.docusign.esign.model.*;
import com.sun.jersey.core.util.Base64;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Arrays;
#Controller
#RequestMapping("/eg008")
public class EG008ControllerCreateTemplate extends EGController {
#Autowired
protected HttpSession session;
#Override
protected void addSpecialAttributes(ModelMap model) {
}
#Override
protected String getEgName() {
return "eg008";
}
#Override
protected String getTitle() {
return "Create a template";
}
#Override
protected String getResponseTitle() {
return "Template results";
}
#Override
// ***DS.snippet.0.start
protected EnvelopeDocumentsResult doWork(WorkArguments args, ModelMap
model,
String accessToken, String
basePath) throws ApiException, IOException {
// Data for this method
// accessToken (argument)
// basePath (argument)
// config.appUrl (url of the application itself)
String accountId = args.getAccountId();
String templateName = "Example Signer and CC template";
// Step 1. list existing templates
ApiClient apiClient = new ApiClient(basePath);
apiClient.addDefaultHeader("Authorization", "Bearer " + accessToken);
TemplatesApi templatesApi = new TemplatesApi(apiClient);
TemplatesApi.ListTemplatesOptions options = templatesApi.new
ListTemplatesOptions();
options.setSearchText(templateName);
// get the results
EnvelopeTemplateResults results =
templatesApi.listTemplates(accountId, options);
// Step 2. process results. Template found?
String templateId;
String resultsTemplateName;
boolean createdNewTemplate;
if (Integer.parseInt(results.getResultSetSize()) > 0) {
// Yes. Save the template id and name
EnvelopeTemplateResult template =
results.getEnvelopeTemplates().get(0);
templateId = template.getTemplateId();
resultsTemplateName = template.getName();
createdNewTemplate = false;
} else {
// No. Make a new template
// Prepare request
args.setTemplateName("Example Signer and CC template");
EnvelopeTemplate templateReqObject = makeTemplate(args);
// Call DocuSign
TemplateSummary template = templatesApi.createTemplate(accountId,
templateReqObject);
// process result
templateId = template.getTemplateId();
resultsTemplateName = template.getName();
createdNewTemplate = true;
}
// Save templateId
session.setAttribute("templateId", templateId);
String msg = createdNewTemplate ?
"The template has been created!" :
"The template already exists in your account.";
setMessage(msg + "<br/>Template name: " + resultsTemplateName + ", ID
" + templateId + ".");
return null;
}
private EnvelopeTemplate makeTemplate(WorkArguments args) throws
IOException {
// document 1 (pdf) has tag /sn1/
//
// The template has two recipient roles.
// recipient 1 - signer
// recipient 2 - cc
// The template will be sent first to the signer.
// After it is signed, a copy is sent to the cc person.
// read file from a local directory
// The reads could raise an exception if the file is not available!
byte[] docPdfBytes = readFile("World_Wide_Corp_fields.pdf");
// add the documents
Document doc = new Document();
String docB64 = new String(Base64.encode(docPdfBytes));
doc.setDocumentBase64(docB64);
doc.setName("Lorem Ipsum"); // can be different from actual file name
doc.setFileExtension("pdf");
doc.setDocumentId("1");
// create a signer recipient to sign the document, identified by name
and email
// We're setting the parameters via the object creation
Signer signer1 = new Signer();
signer1.setRoleName("signer");
signer1.setRecipientId("1");
signer1.setRoutingOrder("1");
// routingOrder (lower means earlier) determines the order of
deliveries
// to the recipients. Parallel routing order is supported by using
the
// same integer as the order for two or more recipients.
// create a cc recipient to receive a copy of the documents,
identified by name and email
// We're setting the parameters via setters
CarbonCopy cc1 = new CarbonCopy();
cc1.setRoleName("cc");
cc1.setRoutingOrder("2");
cc1.setRecipientId("2");
// Create fields using absolute positioning:
SignHere signHere = new SignHere();
signHere.setDocumentId("1");
signHere.setPageNumber("1");
signHere.setXPosition("191");
signHere.setYPosition("148");
Checkbox check1 = new Checkbox();
check1.setDocumentId("1");
check1.setPageNumber("1");
check1.setXPosition("75");
check1.setYPosition("417");
check1.setTabLabel("ckAuthorization");
Checkbox check2 = new Checkbox();
check2.setDocumentId("1");
check2.setPageNumber("1");
check2.setXPosition("75");
check2.setYPosition("447");
check2.setTabLabel("ckAuthentication");
Checkbox check3 = new Checkbox();
check3.setDocumentId("1");
check3.setPageNumber("1");
check3.setXPosition("75");
check3.setYPosition("478");
check3.setTabLabel("ckAgreement");
Checkbox check4 = new Checkbox();
check4.setDocumentId("1");
check4.setPageNumber("1");
check4.setXPosition("75");
check4.setYPosition("508");
check4.setTabLabel("ckAcknowledgement");
List list1 = new List();
list1.setDocumentId("1");
list1.setPageNumber("1");
list1.setXPosition("142");
list1.setYPosition("291");
list1.setFont("helvetica");
list1.setFontSize("size14");
list1.setTabLabel("list");
list1.setRequired("false");
list1.setListItems(Arrays.asList(
createListItem("Red"),
createListItem("Orange"),
createListItem("Yellow"),
createListItem("Green"),
createListItem("Blue"),
createListItem("Indigo"),
createListItem("Violet")
));
// The SDK can't create a number tab at this time. Bug DCM-2732
// Until it is fixed, use a text tab instead.
// , number = docusign.Number.constructFromObject({
// documentId: "1", pageNumber: "1", xPosition: "163",
yPosition: "260",
// font: "helvetica", fontSize: "size14", tabLabel:
"numbersOnly",
// height: "23", width: "84", required: "false"})
Text textInsteadOfNumber = new Text();
textInsteadOfNumber.setDocumentId("1");
textInsteadOfNumber.setPageNumber("1");
textInsteadOfNumber.setXPosition("153");
textInsteadOfNumber.setYPosition("260");
textInsteadOfNumber.setFont("helvetica");
textInsteadOfNumber.setFontSize("size14");
textInsteadOfNumber.setTabLabel("numbersOnly");
textInsteadOfNumber.setHeight(23);
textInsteadOfNumber.setWidth(84);
textInsteadOfNumber.required("false");
RadioGroup radioGroup = new RadioGroup();
radioGroup.setDocumentId("1");
radioGroup.setGroupName("radio1");
radioGroup.setRadios(Arrays.asList(
createRadio("white", "142"),
createRadio("red", "74"),
createRadio("blue", "220")
));
Text text = new Text();
text.setDocumentId("1");
text.setPageNumber("1");
text.setXPosition("153");
text.setYPosition("230");
text.setFont("helvetica");
text.setFontSize("size14");
text.setTabLabel("text");
text.setHeight(23);
text.setWidth(84);
text.required("false");
// Tabs are set per recipient / signer
Tabs signer1Tabs = new Tabs();
signer1Tabs.setCheckboxTabs(Arrays.asList(check1, check2, check3,
check4));
signer1Tabs.setListTabs(Arrays.asList(list1));
// numberTabs: [number],
signer1Tabs.setRadioGroupTabs(Arrays.asList(radioGroup));
signer1Tabs.setSignHereTabs(Arrays.asList(signHere));
signer1Tabs.textTabs(Arrays.asList(text, textInsteadOfNumber));
signer1.setTabs(signer1Tabs);
// Add the recipients to the env object
Recipients recipients = new Recipients();
recipients.setSigners(Arrays.asList(signer1));
recipients.setCarbonCopies(Arrays.asList(cc1));
// create the envelope template definition object
EnvelopeTemplateDefinition envelopeTemplateDefinition = new
EnvelopeTemplateDefinition();
envelopeTemplateDefinition.setDescription("Example template created
via the API");
envelopeTemplateDefinition.setName(args.getTemplateName());
envelopeTemplateDefinition.setShared("false");
// create the overall template definition
EnvelopeTemplate template = new EnvelopeTemplate();
// The order in the docs array determines the order in the env
template.setDocuments(Arrays.asList(doc));
template.setEmailSubject("Please sign this document");
template.setEnvelopeTemplateDefinition(envelopeTemplateDefinition);
template.setRecipients(recipients);
template.setStatus("created");
return template;
}
private ListItem createListItem(String color) {
ListItem item = new ListItem();
item.setText(color);
item.setValue(color.toLowerCase());
return item;*emphasized text*`enter code here`
}
private Radio createRadio(String value, String xPosition) {
Radio radio = new Radio();
radio.setPageNumber("1");
radio.setValue(value);
radio.setXPosition(xPosition);
radio.setYPosition("384");
radio.setRequired("false");
return radio;
}
// ***DS.snippet.0.end
}
Template created pro-grammatically having conditional logic.
I have an example in C#, does this help?
It creates three Number tabs, once of which is the Conditional Child of a Checkbox tab. A formula tab adds the three number tabs together.
Checkbox checkbox = new Checkbox
{
TabLabel = "ToggleNumber3",
Selected = "True",
XPosition = "10",
YPosition = "10",
DocumentId = "1",
PageNumber = "1",
};
Number number1 = new DocuSign.eSign.Model.Number
{
TabLabel = "Number1",
Value = "1",
RecipientId = "1",
XPosition = "20",
YPosition = "10",
DocumentId = "1",
PageNumber = "1",
};
Number number2 = new Number
{
TabLabel = "Number2",
Value = "2",
XPosition = "30",
YPosition = "10",
DocumentId = "1",
PageNumber = "1",
};
Number number3 = new Number
{
TabLabel = "Number3",
Value = "8",
XPosition = "500",
YPosition = "10",
ConditionalParentLabel = "ToggleNumber3",
ConditionalParentValue = "On",
DocumentId = "1",
PageNumber = "1",
};
FormulaTab additionFormula = new FormulaTab
{
TabLabel = "AdditionFormula",
YPosition = "30",
XPosition = "10",
Formula = "[Number1] + [Number2] + [Number3]",
DocumentId = "1",
PageNumber = "1",
};
// Add the sign here tab array to the signer object.
signer.Tabs = new Tabs
{
SignHereTabs = new List<SignHere>(signHereTabs),
NumberTabs = new List<Number> { number1, number2, number3},
FormulaTabs = new List<FormulaTab> { additionFormula },
CheckboxTabs = new List<Checkbox> { checkbox },
};
I am able to create order using square(v2/locations/location_id/orders)api and getting order id. But I am not able to get this order details and also how I can see this created order on square dashboard? please help me.
I am using the below method for doing it:
public CreateOrderResponse createOrder(String locationId, CreateOrderRequest body) throws ApiException {
Object localVarPostBody = body;
// verify the required parameter 'locationId' is set
if (locationId == null) {
throw new ApiException(400, "Missing the required parameter 'locationId' when calling createOrder");
}
// verify the required parameter 'body' is set
if (body == null) {
throw new ApiException(400, "Missing the required parameter 'body' when calling createOrder");
}
// create path and map variables
String localVarPath = "/v2/locations/{location_id}/orders".replaceAll("\\{" + "location_id" + "\\}",
apiClient.escapeString(locationId.toString()));
// query params
List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
final String[] localVarAccepts = { "application/json" };
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
final String[] localVarContentTypes = { "application/json" };
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { "oauth2" };
GenericType<CreateOrderResponse> localVarReturnType = new GenericType<CreateOrderResponse>() {
};
CompleteResponse<CreateOrderResponse> completeResponse = (CompleteResponse<CreateOrderResponse>) apiClient
.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams,
localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames,
localVarReturnType);
return completeResponse.getData();
}
Thanks
The orders endpoint is only for creating itemized orders for e-commerce transactions. You won't see them anywhere until you charge them, and then you'll see the itemizations for the order in your dashboard with the transaction.
I'm trying to build grid with build in column filtering (using sencha gxt), here is my code:
public Grid<Stock> createGrid() {
// Columns definition
ColumnConfig<Stock, String> nameCol = new ColumnConfig<Stock, String>(props.name(), 100, "Company");
// Column model definition and creation
List<ColumnConfig<Stock, ?>> cl = new ArrayList<ColumnConfig<Stock, ?>>();
cl.add(nameCol);
ColumnModel<Stock> cm = new ColumnModel<Stock>(cl);
// Data populating
ListStore<Stock> store = new ListStore<Stock>(props.key());
store.addAll(TestData.getStocks());
// Grid creation with data
final Grid<Stock> grid = new Grid<Stock>(store, cm);
grid.getView().setAutoExpandColumn(nameCol);
grid.setBorders(false);
grid.getView().setStripeRows(true);
grid.getView().setColumnLines(true);
// Filters definition
StoreFilterField<Stock> filter = new StoreFilterField<Stock>() {
#Override
protected boolean doSelect(Store<Stock> store, Stock parent, Stock item, String filter) {
// Window.alert(String.valueOf("a"));
String name = item.getName();
name = name.toLowerCase();
if (name.startsWith(filter.toLowerCase())) {
return true;
}
return false;
}
};
filter.bind(store);
cm.addHeaderGroup(0, 0, new HeaderGroupConfig(filter, 1, 1));
filter.focus();
return grid;
}
My problem is: after I run this code, I cannot write anything to filter input, I'm using test data and classes (Stock.java and StockProperties.java) from this example: http://sencha.com/examples-dev/#ExamplePlace:filtergrid
I try to put allert in doSelect method to check if this function was called, but it wasn't.
Any idea will be welcome. Thanks.
I was able to make your code work. I observed that there were compiler errors in the code for StoreFilterField class. Here is the code that filters the grid based on the values in the first column, that is, name field in the Stock model.
StoreFilterField<Stock> filter1 = new StoreFilterField<Stock>() {
#Override
protected boolean doSelect(Store<Stock> store, Stock parent, Stock record, String property, String filter) {
String name = record.get("name");
name = name.toLowerCase();
if (name.startsWith(filter.toLowerCase())) {
return true;
}
return false;
}
};
filter1.bind(store);
Btw, I tested this with GXT 2.2.5 and GWT 2.4.
Thanks,
Ganesh
I solve this problem according to this paper http://www.sencha.com/forum/archive/index.php/ … but I replace disableTextSelection(false) with setAllowTextSelection(true);