public class FieldFillIn extends Field
To learn more, visit the Working with Fields documentation article.
Remarks:
Prompts the user to enter text.
Examples:
Shows how to use the FILLIN field to prompt the user for a response.
public void fieldFillIn() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a FILLIN field. When we manually update this field in Microsoft Word,
// it will prompt us to enter a response. The field will then display the response as text.
FieldFillIn field = (FieldFillIn) builder.insertField(FieldType.FIELD_FILL_IN, true);
field.setPromptText("Please enter a response:");
field.setDefaultResponse("A default response.");
// We can also use these fields to ask the user for a unique response for each page
// created during a mail merge done using Microsoft Word.
field.setPromptOnceOnMailMerge(true);
Assert.assertEquals(" FILLIN \"Please enter a response:\" \\d \"A default response.\" \\o", field.getFieldCode());
FieldMergeField mergeField = (FieldMergeField) builder.insertField(FieldType.FIELD_MERGE_FIELD, true);
mergeField.setFieldName("MergeField");
// If we perform a mail merge programmatically, we can use a custom prompt respondent
// to automatically edit responses for FILLIN fields that the mail merge encounters.
doc.getFieldOptions().setUserPromptRespondent(new PromptRespondent());
doc.getMailMerge().execute(new String[]{"MergeField"}, new Object[]{""});
doc.updateFields();
doc.save(getArtifactsDir() + "Field.FILLIN.docx");
}
/// <summary>
/// Prepends a line to the default response of every FILLIN field during a mail merge.
/// </summary>
private static class PromptRespondent implements IFieldUserPromptRespondent {
public String respond(final String promptText, final String defaultResponse) {
return "Response modified by PromptRespondent. " + defaultResponse;
}
}
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getDefaultResponse()
Gets default user response (initial value contained in the prompt window).
|
boolean |
getPromptOnceOnMailMerge()
Gets whether the user response should be recieved once per a mail merge operation.
|
java.lang.String |
getPromptText()
Gets the prompt text (the title of the prompt window).
|
int |
getSwitchType(java.lang.String switchName) |
void |
setDefaultResponse(java.lang.String value)
Sets default user response (initial value contained in the prompt window).
|
void |
setPromptOnceOnMailMerge(boolean value)
Sets whether the user response should be recieved once per a mail merge operation.
|
void |
setPromptText(java.lang.String value)
Sets the prompt text (the title of the prompt window).
|
getDisplayResult, getEnd, getFieldCode, getFieldCode, getFormat, getLocaleId, getResult, getSeparator, getStart, getType, isDirty, isDirty, isLocked, isLocked, needStoreOldResultNodes, remove, setLocaleId, setResult, unlink, update, updatepublic int getSwitchType(java.lang.String switchName)
public java.lang.String getPromptText()
Examples:
Shows how to use the FILLIN field to prompt the user for a response.
public void fieldFillIn() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a FILLIN field. When we manually update this field in Microsoft Word,
// it will prompt us to enter a response. The field will then display the response as text.
FieldFillIn field = (FieldFillIn) builder.insertField(FieldType.FIELD_FILL_IN, true);
field.setPromptText("Please enter a response:");
field.setDefaultResponse("A default response.");
// We can also use these fields to ask the user for a unique response for each page
// created during a mail merge done using Microsoft Word.
field.setPromptOnceOnMailMerge(true);
Assert.assertEquals(" FILLIN \"Please enter a response:\" \\d \"A default response.\" \\o", field.getFieldCode());
FieldMergeField mergeField = (FieldMergeField) builder.insertField(FieldType.FIELD_MERGE_FIELD, true);
mergeField.setFieldName("MergeField");
// If we perform a mail merge programmatically, we can use a custom prompt respondent
// to automatically edit responses for FILLIN fields that the mail merge encounters.
doc.getFieldOptions().setUserPromptRespondent(new PromptRespondent());
doc.getMailMerge().execute(new String[]{"MergeField"}, new Object[]{""});
doc.updateFields();
doc.save(getArtifactsDir() + "Field.FILLIN.docx");
}
/// <summary>
/// Prepends a line to the default response of every FILLIN field during a mail merge.
/// </summary>
private static class PromptRespondent implements IFieldUserPromptRespondent {
public String respond(final String promptText, final String defaultResponse) {
return "Response modified by PromptRespondent. " + defaultResponse;
}
}
public void setPromptText(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to use the FILLIN field to prompt the user for a response.
public void fieldFillIn() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a FILLIN field. When we manually update this field in Microsoft Word,
// it will prompt us to enter a response. The field will then display the response as text.
FieldFillIn field = (FieldFillIn) builder.insertField(FieldType.FIELD_FILL_IN, true);
field.setPromptText("Please enter a response:");
field.setDefaultResponse("A default response.");
// We can also use these fields to ask the user for a unique response for each page
// created during a mail merge done using Microsoft Word.
field.setPromptOnceOnMailMerge(true);
Assert.assertEquals(" FILLIN \"Please enter a response:\" \\d \"A default response.\" \\o", field.getFieldCode());
FieldMergeField mergeField = (FieldMergeField) builder.insertField(FieldType.FIELD_MERGE_FIELD, true);
mergeField.setFieldName("MergeField");
// If we perform a mail merge programmatically, we can use a custom prompt respondent
// to automatically edit responses for FILLIN fields that the mail merge encounters.
doc.getFieldOptions().setUserPromptRespondent(new PromptRespondent());
doc.getMailMerge().execute(new String[]{"MergeField"}, new Object[]{""});
doc.updateFields();
doc.save(getArtifactsDir() + "Field.FILLIN.docx");
}
/// <summary>
/// Prepends a line to the default response of every FILLIN field during a mail merge.
/// </summary>
private static class PromptRespondent implements IFieldUserPromptRespondent {
public String respond(final String promptText, final String defaultResponse) {
return "Response modified by PromptRespondent. " + defaultResponse;
}
}
value - The prompt text (the title of the prompt window).java.lang.Exceptionpublic boolean getPromptOnceOnMailMerge()
Examples:
Shows how to use the FILLIN field to prompt the user for a response.
public void fieldFillIn() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a FILLIN field. When we manually update this field in Microsoft Word,
// it will prompt us to enter a response. The field will then display the response as text.
FieldFillIn field = (FieldFillIn) builder.insertField(FieldType.FIELD_FILL_IN, true);
field.setPromptText("Please enter a response:");
field.setDefaultResponse("A default response.");
// We can also use these fields to ask the user for a unique response for each page
// created during a mail merge done using Microsoft Word.
field.setPromptOnceOnMailMerge(true);
Assert.assertEquals(" FILLIN \"Please enter a response:\" \\d \"A default response.\" \\o", field.getFieldCode());
FieldMergeField mergeField = (FieldMergeField) builder.insertField(FieldType.FIELD_MERGE_FIELD, true);
mergeField.setFieldName("MergeField");
// If we perform a mail merge programmatically, we can use a custom prompt respondent
// to automatically edit responses for FILLIN fields that the mail merge encounters.
doc.getFieldOptions().setUserPromptRespondent(new PromptRespondent());
doc.getMailMerge().execute(new String[]{"MergeField"}, new Object[]{""});
doc.updateFields();
doc.save(getArtifactsDir() + "Field.FILLIN.docx");
}
/// <summary>
/// Prepends a line to the default response of every FILLIN field during a mail merge.
/// </summary>
private static class PromptRespondent implements IFieldUserPromptRespondent {
public String respond(final String promptText, final String defaultResponse) {
return "Response modified by PromptRespondent. " + defaultResponse;
}
}
public void setPromptOnceOnMailMerge(boolean value)
throws java.lang.Exception
Examples:
Shows how to use the FILLIN field to prompt the user for a response.
public void fieldFillIn() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a FILLIN field. When we manually update this field in Microsoft Word,
// it will prompt us to enter a response. The field will then display the response as text.
FieldFillIn field = (FieldFillIn) builder.insertField(FieldType.FIELD_FILL_IN, true);
field.setPromptText("Please enter a response:");
field.setDefaultResponse("A default response.");
// We can also use these fields to ask the user for a unique response for each page
// created during a mail merge done using Microsoft Word.
field.setPromptOnceOnMailMerge(true);
Assert.assertEquals(" FILLIN \"Please enter a response:\" \\d \"A default response.\" \\o", field.getFieldCode());
FieldMergeField mergeField = (FieldMergeField) builder.insertField(FieldType.FIELD_MERGE_FIELD, true);
mergeField.setFieldName("MergeField");
// If we perform a mail merge programmatically, we can use a custom prompt respondent
// to automatically edit responses for FILLIN fields that the mail merge encounters.
doc.getFieldOptions().setUserPromptRespondent(new PromptRespondent());
doc.getMailMerge().execute(new String[]{"MergeField"}, new Object[]{""});
doc.updateFields();
doc.save(getArtifactsDir() + "Field.FILLIN.docx");
}
/// <summary>
/// Prepends a line to the default response of every FILLIN field during a mail merge.
/// </summary>
private static class PromptRespondent implements IFieldUserPromptRespondent {
public String respond(final String promptText, final String defaultResponse) {
return "Response modified by PromptRespondent. " + defaultResponse;
}
}
value - Whether the user response should be recieved once per a mail merge operation.java.lang.Exceptionpublic java.lang.String getDefaultResponse()
Examples:
Shows how to use the FILLIN field to prompt the user for a response.
public void fieldFillIn() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a FILLIN field. When we manually update this field in Microsoft Word,
// it will prompt us to enter a response. The field will then display the response as text.
FieldFillIn field = (FieldFillIn) builder.insertField(FieldType.FIELD_FILL_IN, true);
field.setPromptText("Please enter a response:");
field.setDefaultResponse("A default response.");
// We can also use these fields to ask the user for a unique response for each page
// created during a mail merge done using Microsoft Word.
field.setPromptOnceOnMailMerge(true);
Assert.assertEquals(" FILLIN \"Please enter a response:\" \\d \"A default response.\" \\o", field.getFieldCode());
FieldMergeField mergeField = (FieldMergeField) builder.insertField(FieldType.FIELD_MERGE_FIELD, true);
mergeField.setFieldName("MergeField");
// If we perform a mail merge programmatically, we can use a custom prompt respondent
// to automatically edit responses for FILLIN fields that the mail merge encounters.
doc.getFieldOptions().setUserPromptRespondent(new PromptRespondent());
doc.getMailMerge().execute(new String[]{"MergeField"}, new Object[]{""});
doc.updateFields();
doc.save(getArtifactsDir() + "Field.FILLIN.docx");
}
/// <summary>
/// Prepends a line to the default response of every FILLIN field during a mail merge.
/// </summary>
private static class PromptRespondent implements IFieldUserPromptRespondent {
public String respond(final String promptText, final String defaultResponse) {
return "Response modified by PromptRespondent. " + defaultResponse;
}
}
public void setDefaultResponse(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to use the FILLIN field to prompt the user for a response.
public void fieldFillIn() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a FILLIN field. When we manually update this field in Microsoft Word,
// it will prompt us to enter a response. The field will then display the response as text.
FieldFillIn field = (FieldFillIn) builder.insertField(FieldType.FIELD_FILL_IN, true);
field.setPromptText("Please enter a response:");
field.setDefaultResponse("A default response.");
// We can also use these fields to ask the user for a unique response for each page
// created during a mail merge done using Microsoft Word.
field.setPromptOnceOnMailMerge(true);
Assert.assertEquals(" FILLIN \"Please enter a response:\" \\d \"A default response.\" \\o", field.getFieldCode());
FieldMergeField mergeField = (FieldMergeField) builder.insertField(FieldType.FIELD_MERGE_FIELD, true);
mergeField.setFieldName("MergeField");
// If we perform a mail merge programmatically, we can use a custom prompt respondent
// to automatically edit responses for FILLIN fields that the mail merge encounters.
doc.getFieldOptions().setUserPromptRespondent(new PromptRespondent());
doc.getMailMerge().execute(new String[]{"MergeField"}, new Object[]{""});
doc.updateFields();
doc.save(getArtifactsDir() + "Field.FILLIN.docx");
}
/// <summary>
/// Prepends a line to the default response of every FILLIN field during a mail merge.
/// </summary>
private static class PromptRespondent implements IFieldUserPromptRespondent {
public String respond(final String promptText, final String defaultResponse) {
return "Response modified by PromptRespondent. " + defaultResponse;
}
}
value - Default user response (initial value contained in the prompt window).java.lang.Exception