public class FieldUserAddress extends Field
To learn more, visit the Working with Fields documentation article.
Remarks:
Retrieves the current user's postal address.
Examples:
Shows how to use the USERADDRESS field.
Document doc = new Document();
// Create a UserInformation object and set it as the source of user information for any fields that we create.
UserInformation userInformation = new UserInformation();
userInformation.setAddress("123 Main Street");
doc.getFieldOptions().setCurrentUser(userInformation);
// Create a USERADDRESS field to display the current user's address,
// taken from the UserInformation object we created above.
DocumentBuilder builder = new DocumentBuilder(doc);
FieldUserAddress fieldUserAddress = (FieldUserAddress) builder.insertField(FieldType.FIELD_USER_ADDRESS, true);
Assert.assertEquals(" USERADDRESS ", fieldUserAddress.getFieldCode());
Assert.assertEquals("123 Main Street", fieldUserAddress.getResult());
// We can set this property to get our field to override the value currently stored in the UserInformation object.
fieldUserAddress.setUserAddress("456 North Road");
fieldUserAddress.update();
Assert.assertEquals(" USERADDRESS \"456 North Road\"", fieldUserAddress.getFieldCode());
Assert.assertEquals("456 North Road", fieldUserAddress.getResult());
// This does not affect the value in the UserInformation object.
Assert.assertEquals("123 Main Street", doc.getFieldOptions().getCurrentUser().getAddress());
doc.updateFields();
doc.save(getArtifactsDir() + "Field.USERADDRESS.docx");
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getUserAddress()
Gets the current user's postal address.
|
void |
setUserAddress(java.lang.String value)
Sets the current user's postal address.
|
getDisplayResult, getEnd, getFieldCode, getFieldCode, getFormat, getLocaleId, getResult, getSeparator, getStart, getType, isDirty, isDirty, isLocked, isLocked, needStoreOldResultNodes, remove, setLocaleId, setResult, unlink, update, updatepublic java.lang.String getUserAddress()
Examples:
Shows how to use the USERADDRESS field.
Document doc = new Document();
// Create a UserInformation object and set it as the source of user information for any fields that we create.
UserInformation userInformation = new UserInformation();
userInformation.setAddress("123 Main Street");
doc.getFieldOptions().setCurrentUser(userInformation);
// Create a USERADDRESS field to display the current user's address,
// taken from the UserInformation object we created above.
DocumentBuilder builder = new DocumentBuilder(doc);
FieldUserAddress fieldUserAddress = (FieldUserAddress) builder.insertField(FieldType.FIELD_USER_ADDRESS, true);
Assert.assertEquals(" USERADDRESS ", fieldUserAddress.getFieldCode());
Assert.assertEquals("123 Main Street", fieldUserAddress.getResult());
// We can set this property to get our field to override the value currently stored in the UserInformation object.
fieldUserAddress.setUserAddress("456 North Road");
fieldUserAddress.update();
Assert.assertEquals(" USERADDRESS \"456 North Road\"", fieldUserAddress.getFieldCode());
Assert.assertEquals("456 North Road", fieldUserAddress.getResult());
// This does not affect the value in the UserInformation object.
Assert.assertEquals("123 Main Street", doc.getFieldOptions().getCurrentUser().getAddress());
doc.updateFields();
doc.save(getArtifactsDir() + "Field.USERADDRESS.docx");
public void setUserAddress(java.lang.String value)
throws java.lang.Exception
Examples:
Shows how to use the USERADDRESS field.
Document doc = new Document();
// Create a UserInformation object and set it as the source of user information for any fields that we create.
UserInformation userInformation = new UserInformation();
userInformation.setAddress("123 Main Street");
doc.getFieldOptions().setCurrentUser(userInformation);
// Create a USERADDRESS field to display the current user's address,
// taken from the UserInformation object we created above.
DocumentBuilder builder = new DocumentBuilder(doc);
FieldUserAddress fieldUserAddress = (FieldUserAddress) builder.insertField(FieldType.FIELD_USER_ADDRESS, true);
Assert.assertEquals(" USERADDRESS ", fieldUserAddress.getFieldCode());
Assert.assertEquals("123 Main Street", fieldUserAddress.getResult());
// We can set this property to get our field to override the value currently stored in the UserInformation object.
fieldUserAddress.setUserAddress("456 North Road");
fieldUserAddress.update();
Assert.assertEquals(" USERADDRESS \"456 North Road\"", fieldUserAddress.getFieldCode());
Assert.assertEquals("456 North Road", fieldUserAddress.getResult());
// This does not affect the value in the UserInformation object.
Assert.assertEquals("123 Main Street", doc.getFieldOptions().getCurrentUser().getAddress());
doc.updateFields();
doc.save(getArtifactsDir() + "Field.USERADDRESS.docx");
value - The current user's postal address.java.lang.Exception