Giancarlo,
I used uploadPage.createNodeData("title").setValue("Upload Bin") and
this did the trick perfectly. Thank you very much for your help!
Adam
Giancarlo F. Berner wrote:
Adam,
Thanks for the very precise information.
The MetaData-Title is not the same like the Page-Title. The MetaData
node one the webpage's child nodes of type nt:file containing
additional information about it's parent. So I suppose the
MetaData.setTitle() method writes the title of the MetaData-Node. But
I am not quite sure, will have to dig into the source.
Supposing though you want to write the page title, you may want to add
the following line of code (check below script you provided):
uploadPage.createNodeData("title").setValue("Upload Bin");
You do not need to write the title of the MetaData, but the Page
Title. That's the one visible in the Admin.
/giancarlo
Adam Cooper wrote:
Giancarlo,
I am writing a file manager that stores uploaded files in a page
which gets created on the fly when it does not exist. This page is
visible in Admin Central as it is stored in the website portion of
the magnolia repository. I want to change the title which is
displayed in adminCentral for "prettiness" sake only as the rest of
the functionality of the manager works just fine. I am aware of the
other ways to change the title but I would rather it be automated by
the file manager. This way, if the authors who will use this file
manager want to clear out all the files in the upload bin, they can
just delete the page. The next time they open the file manager it
will create a new empty bin on the fly and they can then upload files
to the newly created bin.
Here is a slightly larger view of the code I am working on if it
helps. (It has been slightly doctored from its original form for
conciseness sake)
String repository = "website";
HierarchyManager hm =
SessionAccessControl.getHierarchyManager(request, repository);
String path = "/public/upload"
Content uploadPage = null;
try {
uploadPage = hm.getContent(path);
} catch (RepositoryException e) {
String parentPath = StringUtils.substringBeforeLast(path, "/");
String label = StringUtils.substringAfterLast(path, "/");
if (StringUtils.isEmpty(parentPath)) {
uploadPage = hm.getRoot();
} else {
uploadPage = hm.getContent(parentPath);
}
uploadPage = uploadPage.createContent(label, ItemType.CONTENT);
uploadPage.createNodeData("title").setValue("Upload Bin");
// Set the title and template. Update meta info and save.
uploadPage.getMetaData().setTitle("Upload Bin"); // FIXME: Won't
update title which is displayed in adminCentral
uploadPage.getMetaData().setTemplate("pulseUploadBin");
uploadPage.getMetaData().setSequencePosition();
uploadPage.updateMetaData(request);
uploadPage.save();
System.out.println("uploadPage.getTitle() =
"+uploadPage.getTitle()); // Prints "uploadPage.getTitle() = "
System.out.println("uploadPage.getMetaData().getTitle() =
"+uploadPage.getMetaData().getTitle()); // Prints
"uploadPage.getMetaData().getTitle() = Upload Bin"
}
There are no errors generated in any log file. The title is just a
blank "-" in adminCentral as if I just right clicked and selected
"New Page" without making any changes. If I do
System.out.println(uploadPage.getMetaData().getTitle()) after the
code block I have shown, it returns "Upload Bin" as expected, but if
I do System.out.println(uploadPage.getTitle()) it returns nothing.
There is no nice and easy setTitle() for the Content class and I
would expect the later println to return the title that I actually
want so I am not even sure if I am modifying the correct piece of
data. Thanks for any suggestions you can offer.
Adam Cooper
Associate Developer
Talisen Technologies
[EMAIL PROTECTED]
----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/magnolia/developer.html
----------------------------------------------------------------