cancel
Showing results for 
Search instead for 
Did you mean: 

Make user select categories after adding content

wiggum
Champ in-the-making
Champ in-the-making
What's the best way to change the Add Content Dialog so that after a user uploads a file, they are brought to the "Select Categories" page (under View Details) for that document?
16 REPLIES 16

gavinc
Champ in-the-making
Champ in-the-making
You'll need to override the AddContentDialog bean and return a different outcome. Have a look at doPostCommitProcessing() for an example.

wiggum
Champ in-the-making
Champ in-the-making
So far so good – but the filename shows up as blank when I call the editCategory dialog from my overridding bean.  How can I make sure that dialog can show the filename?

You'll need to override the AddContentDialog bean and return a different outcome. Have a look at doPostCommitProcessing() for an example.

gavinc
Champ in-the-making
Champ in-the-making
Whenever you are 'acting' upon an object in the web client there is a Node object representing the item. The properties are retrieved from the Node object instance. If the editCategory dialog is showing a blank filename it probably means the Node object has not been setup yet or the properties have not been refreshed.

If you are launching the editCategory dialog from within the AddContent dialog i.e. before pressing finish, the Node object will not be created yet, which is more than likely the cause of the issue you are seeing.

Another way you could achieve the same thing is to setup the categories aspect in your bean when the node is created and then have the property sheet that shows up after adding content be configured to show categories?

wiggum
Champ in-the-making
Champ in-the-making
Thanks Gavin, I really appreciate your response. 

So the node does not get created until the user selects the "Finish" button in the dialog?  I am calling the "editCategories" dialog from my own "AddContentDialog" extended class.

I'm interested in pursuing this solution:

Another way you could achieve the same thing is to setup the categories aspect in your bean when the node is created and then have the property sheet that shows up after adding content be configured to show categories?

but I don't completely follow.  Any chance you can expand?

Thanks!

gavinc
Champ in-the-making
Champ in-the-making
Sure.

Correct, the node is created during the processing of the Finish button, so if you call the editCategories dialog before the node will be null.

As for the other solution….in your finishImpl method you could add the "generalclassifiable" aspect to the node you created. This will add a cm:categories property to the new node.

Then in the property sheet configuration for your type (or for the standard content type) you could add the following:

<show-property name="categories" />

If you just use the standard Add Content dialog and allow it to show the set properties dilaog after Finish has been pressed you should see an entry titled "Categories".

wiggum
Champ in-the-making
Champ in-the-making
That is a really slick way to do it – it looks great! 

Thanks Gavin!

wiggum
Champ in-the-making
Champ in-the-making
Hi, when I use my own Add Content Dialog (which uses all the same code as the original Add Content Dialog), that once I upload a file, if I click "Add Content" again, the last uploaded file persists.

So in this code in the JSP:

myAddContentDialog dialog = (myAddContentDialog)FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "myAddContentDialog");
if (dialog != null && dialog.getFileName() != null)
{
   fileUploaded = true;
}

fileUploaded is always returning true after I upload a file.  So I can't upload another one.  In my finishImpl(), I'm calling saveContent then returning "browse". 

Any ideas would be greatly appreciated.

wiggum
Champ in-the-making
Champ in-the-making
Any ideas on this?

gavinc
Champ in-the-making
Champ in-the-making
Firstly, apologies for the delay in replying, I had an extended Christmas holiday this year.

Secondly, yes I have an idea!

In browse.jsp there is the line below (line 130):

<a:actionLink value="#{msg.add_content}" image="/images/icons/add.gif" padding="2" action="addContent" actionListener="#{AddContentDialog.start}" style="white-space:nowrap" id="link3" />

I'm guessing that you have not changed the AddContentDialog reference here to your dialog bean i.e. "myAddContentDialog". If this is the case the fileName property in your bean will not get reset and have the side effect you mention.

Also you shouldn't need to duplicate the code from AddContentDialog, just extend the class and override finishImpl() i.e.

@Override
protected String finishImpl(FacesContext context, String outcome)
      throws Exception
{
   super.finishImpl(context, outcome);

   // your code here

   return "browse";
}

Hope that helps!