public class FieldGlossary extends Field
To learn more, visit the Working with Fields documentation article.
Remarks:
Inserts a glossary entry.
Examples:
Shows how to display a building block with AUTOTEXT and GLOSSARY fields.
Document doc = new Document();
// Create a glossary document and add an AutoText building block to it.
doc.setGlossaryDocument(new GlossaryDocument());
BuildingBlock buildingBlock = new BuildingBlock(doc.getGlossaryDocument());
buildingBlock.setName("MyBlock");
buildingBlock.setGallery(BuildingBlockGallery.AUTO_TEXT);
buildingBlock.setCategory("General");
buildingBlock.setDescription("MyBlock description");
buildingBlock.setBehavior(BuildingBlockBehavior.PARAGRAPH);
doc.getGlossaryDocument().appendChild(buildingBlock);
// Create a source and add it as text to our building block.
Document buildingBlockSource = new Document();
DocumentBuilder buildingBlockSourceBuilder = new DocumentBuilder(buildingBlockSource);
buildingBlockSourceBuilder.writeln("Hello World!");
Node buildingBlockContent = doc.getGlossaryDocument().importNode(buildingBlockSource.getFirstSection(), true);
buildingBlock.appendChild(buildingBlockContent);
// Set a file which contains parts that our document, or its attached template may not contain.
doc.getFieldOptions().setBuiltInTemplatesPaths(new String[]{getMyDir() + "Busniess brochure.dotx"});
DocumentBuilder builder = new DocumentBuilder(doc);
// Below are two ways to use fields to display the contents of our building block.
// 1 - Using an AUTOTEXT field:
FieldAutoText fieldAutoText = (FieldAutoText) builder.insertField(FieldType.FIELD_AUTO_TEXT, true);
fieldAutoText.setEntryName("MyBlock");
Assert.assertEquals(" AUTOTEXT MyBlock", fieldAutoText.getFieldCode());
// 2 - Using a GLOSSARY field:
FieldGlossary fieldGlossary = (FieldGlossary) builder.insertField(FieldType.FIELD_GLOSSARY, true);
fieldGlossary.setEntryName("MyBlock");
Assert.assertEquals(fieldGlossary.getFieldCode(), " GLOSSARY MyBlock");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.AUTOTEXT.GLOSSARY.dotx");
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getEntryName()
Gets the name of the glossary entry to insert.
|
void |
setEntryName(java.lang.String value)
Sets the name of the glossary entry to insert.
|
getDisplayResult, getEnd, getFieldCode, getFieldCode, getFormat, getLocaleId, getResult, getSeparator, getStart, getType, isDirty, isDirty, isLocked, isLocked, needStoreOldResultNodes, remove, setLocaleId, setResult, unlink, update, updatepublic java.lang.String getEntryName()
Examples:
Shows how to display a building block with AUTOTEXT and GLOSSARY fields.
Document doc = new Document();
// Create a glossary document and add an AutoText building block to it.
doc.setGlossaryDocument(new GlossaryDocument());
BuildingBlock buildingBlock = new BuildingBlock(doc.getGlossaryDocument());
buildingBlock.setName("MyBlock");
buildingBlock.setGallery(BuildingBlockGallery.AUTO_TEXT);
buildingBlock.setCategory("General");
buildingBlock.setDescription("MyBlock description");
buildingBlock.setBehavior(BuildingBlockBehavior.PARAGRAPH);
doc.getGlossaryDocument().appendChild(buildingBlock);
// Create a source and add it as text to our building block.
Document buildingBlockSource = new Document();
DocumentBuilder buildingBlockSourceBuilder = new DocumentBuilder(buildingBlockSource);
buildingBlockSourceBuilder.writeln("Hello World!");
Node buildingBlockContent = doc.getGlossaryDocument().importNode(buildingBlockSource.getFirstSection(), true);
buildingBlock.appendChild(buildingBlockContent);
// Set a file which contains parts that our document, or its attached template may not contain.
doc.getFieldOptions().setBuiltInTemplatesPaths(new String[]{getMyDir() + "Busniess brochure.dotx"});
DocumentBuilder builder = new DocumentBuilder(doc);
// Below are two ways to use fields to display the contents of our building block.
// 1 - Using an AUTOTEXT field:
FieldAutoText fieldAutoText = (FieldAutoText) builder.insertField(FieldType.FIELD_AUTO_TEXT, true);
fieldAutoText.setEntryName("MyBlock");
Assert.assertEquals(" AUTOTEXT MyBlock", fieldAutoText.getFieldCode());
// 2 - Using a GLOSSARY field:
FieldGlossary fieldGlossary = (FieldGlossary) builder.insertField(FieldType.FIELD_GLOSSARY, true);
fieldGlossary.setEntryName("MyBlock");
Assert.assertEquals(fieldGlossary.getFieldCode(), " GLOSSARY MyBlock");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.AUTOTEXT.GLOSSARY.dotx");
public void setEntryName(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to display a building block with AUTOTEXT and GLOSSARY fields.
Document doc = new Document();
// Create a glossary document and add an AutoText building block to it.
doc.setGlossaryDocument(new GlossaryDocument());
BuildingBlock buildingBlock = new BuildingBlock(doc.getGlossaryDocument());
buildingBlock.setName("MyBlock");
buildingBlock.setGallery(BuildingBlockGallery.AUTO_TEXT);
buildingBlock.setCategory("General");
buildingBlock.setDescription("MyBlock description");
buildingBlock.setBehavior(BuildingBlockBehavior.PARAGRAPH);
doc.getGlossaryDocument().appendChild(buildingBlock);
// Create a source and add it as text to our building block.
Document buildingBlockSource = new Document();
DocumentBuilder buildingBlockSourceBuilder = new DocumentBuilder(buildingBlockSource);
buildingBlockSourceBuilder.writeln("Hello World!");
Node buildingBlockContent = doc.getGlossaryDocument().importNode(buildingBlockSource.getFirstSection(), true);
buildingBlock.appendChild(buildingBlockContent);
// Set a file which contains parts that our document, or its attached template may not contain.
doc.getFieldOptions().setBuiltInTemplatesPaths(new String[]{getMyDir() + "Busniess brochure.dotx"});
DocumentBuilder builder = new DocumentBuilder(doc);
// Below are two ways to use fields to display the contents of our building block.
// 1 - Using an AUTOTEXT field:
FieldAutoText fieldAutoText = (FieldAutoText) builder.insertField(FieldType.FIELD_AUTO_TEXT, true);
fieldAutoText.setEntryName("MyBlock");
Assert.assertEquals(" AUTOTEXT MyBlock", fieldAutoText.getFieldCode());
// 2 - Using a GLOSSARY field:
FieldGlossary fieldGlossary = (FieldGlossary) builder.insertField(FieldType.FIELD_GLOSSARY, true);
fieldGlossary.setEntryName("MyBlock");
Assert.assertEquals(fieldGlossary.getFieldCode(), " GLOSSARY MyBlock");
doc.updateFields();
doc.save(getArtifactsDir() + "Field.AUTOTEXT.GLOSSARY.dotx");
value - The name of the glossary entry to insert.java.lang.Exception