掲示板
getting value from DLFileEntry fieldsMap
9年前 に Jack Bakker によって更新されました。
getting value from DLFileEntry fieldsMap
Liferay Master 投稿: 978 参加年月日: 10/01/03 最新の投稿
what would be the most direct way to get the "captchaValue" that I am logging in the below ?
long globalGroupId = (GroupLocalServiceUtil.getCompanyGroup(PortalUtil.getDefaultCompanyId())).getGroupId();
long parentFolderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID;
Folder folder = DLAppLocalServiceUtil.getFolder(globalGroupId, parentFolderId, dlFolderName);
long repositoryId = globalGroupId;
//List<fileentry> fileEntries = DLAppServiceUtil.getFileEntries(repositoryId, folder.getFolderId());
List<dlfileentry> fileEntries = DLFileEntryLocalServiceUtil.getFileEntries(globalGroupId,folder.getFolderId());
int randId = new Random().nextInt(fileEntries.size());
DLFileEntry fileEntry = fileEntries.get(randId);
Map fieldsMap = fileEntry.getFieldsMap(fileEntry.getFileVersion().getFileVersionId());
Set<string> keys = fieldsMap.keySet();
for(String key : keys){
log.info("key: " + key);
Collection<fields> fields = fieldsMap.values();
for(Fields curFields : fields){
Field curField = curFields.get("captchaValue");
log.info("value: " + curField.getValue());
}
}
</fields></string></dlfileentry></fileentry>
9年前 に David H Nebinger によって更新されました。
RE: getting value from DLFileEntry fieldsMap
Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿Jack Bakker:
Map fieldsMap = fileEntry.getFieldsMap(fileEntry.getFileVersion().getFileVersionId());
Set<String> keys = fieldsMap.keySet();
// for each key in the map
for(String key : keys){
log.info("key: " + key);
Collection<Fields> fields = fieldsMap.values();
// for each field in the map
for(Fields curFields : fields){
Field curField = curFields.get("captchaValue");
log.info("value: " + curField.getValue());
}
}
Well it won't be through the double iteration... Isn't it just:
Fields fields;
Field field;
for (String key : keys) {
fields = fieldsMap.get(key);
field = fields.get("captchaValue");
if (field != null) {
// have value
}
}
I mean, maybe I'm missing something not included in the context?
9年前 に Jack Bakker によって更新されました。
RE: getting value from DLFileEntry fieldsMap
Liferay Master 投稿: 978 参加年月日: 10/01/03 最新の投稿
It is not iterating over Set or Collection that is the challenge... my original post is intentionally coding-verbose as I learn/share more about Liferay 6.2 documents and media including getting values per metadata fields of a custom Document Type.
Really, I am looking for less lines of code (sets/collection iteration aside for the moment) to get such values which will be useful as number of fields for a Document Type increases.
As a related but somewhat separate is that I read it is better to use DLAppServiceUtil so to cater to multiple types of repositories. However I commented out using that Util because the implementation of FileEntry returned is LiferayFileEntry and I needed a DLFileEntry to get field values.
I see posts on ADT/freemarker to get at the same data, yet given I am new at this, I am finding best practices in this area elusive.
Really, I am looking for less lines of code (sets/collection iteration aside for the moment) to get such values which will be useful as number of fields for a Document Type increases.
As a related but somewhat separate is that I read it is better to use DLAppServiceUtil so to cater to multiple types of repositories. However I commented out using that Util because the implementation of FileEntry returned is LiferayFileEntry and I needed a DLFileEntry to get field values.
I see posts on ADT/freemarker to get at the same data, yet given I am new at this, I am finding best practices in this area elusive.
8年前 に Abdul Kareem によって更新されました。
RE: getting value from DLFileEntry fieldsMap
Junior Member 投稿: 30 参加年月日: 14/09/04 最新の投稿
Hi Jack,
What is capchavalue in this "Field curField = curFields.get("captchaValue");" statement?
Thanks,
Abdul
What is capchavalue in this "Field curField = curFields.get("captchaValue");" statement?
Thanks,
Abdul
8年前 に David H Nebinger によって更新されました。
RE: getting value from DLFileEntry fieldsMap
Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
I think Jack had a captcha in his DDL and was getting the value to verify the captcha result.
8年前 に Jack Bakker によって更新されました。
RE: getting value from DLFileEntry fieldsMap
Liferay Master 投稿: 978 参加年月日: 10/01/03 最新の投稿David H Nebinger:
I think Jack had a captcha in his DDL and was getting the value to verify the captcha result.
correct