cancel
Showing results for 
Search instead for 
Did you mean: 

new dialog for new space type

alpha
Champ in-the-making
Champ in-the-making
i want to add new fields to the space creation dialog
let's say 2 fields : fieldOne, fieldTwo (string fields).

I have created a new action "Create my space" that launches a dialog

<action id="create_myspace">
          <permissions>
             <permission allow="true">CreateChildren</permission>
          </permissions>
          <label-id>create_myspace</label-id>
          <image>/images/icons/create_myspace.gif</image>
          <action>dialog:createMySpace</action>
       </action>
and for the dialog here is the code

<dialog name="createMySpace" page="/jsp/app/space/create-myspace-dialog.jsp" managed-bean="CreateMySpaceDialog"
                icon="/images/icons/create_myspace_large.gif" title-id="create_myspace"
                description-id="create_myspace_description" error-message-id="error_create_myspace_dialog" />


all this code is put in web-client-config-custom.xml

the code for create-myspace-dialog.jsp is taken from alfresco's create-space-dialog.jsp with just little modification to put input field
for fieldOne, and fieldTwo.
I have also created the bean CreateMySpaceDialog, which (like CreateSpaceDialog) extends CreateSpaceWizard, and has the new fields fieldOne and fieldTwo with accessors
i have rewritten getSummary :

public String getSummary() {
      ResourceBundle bundle = Application.getBundle(FacesContext
            .getCurrentInstance());
      return buildSummary(new String[] { bundle.getString("name"),
            bundle.getString("myspace_fieldOne"),
            bundle.getString("myspace_fieldTwo"),
            bundle.getString("description") }, new String[] { this.name,
            this.fieldOne,this.fieldTwo, this.description });
   }


If i create a new space by launching the action "Create my space", it opens the create-myspace-dialog.jsp, and i fill all the fields, but if i want to see my newly created space in details view, it doesn't display fieldOne et and fieldTwo informations.

Am i missing something? If i create a new type model, how do i link it with my dialog bean (so that the created element is of my new type model)?

Any help is appreciated.
8 REPLIES 8

kevinr
Star Contributor
Star Contributor
Are saying that the custom dialog is working ok - but you can't see the resulting custom properties in the Details screen? This is probably because you need a little additional config to add your custom properties to that screen, see:
http://wiki.alfresco.com/wiki/Displaying_Custom_Metadata

Thanks,

Kevin

alpha
Champ in-the-making
Champ in-the-making
thanks for your help!

Are saying that the custom dialog is working ok - but you can't see the resulting custom properties in the Details screen?
in fact i don't know if it's really working, but i don't have any errors, neither can i display the custom fields…
actually, i have read that wiki page, but it didn't help me much this time…because even if i create a new content type (for my new space type) i don't know how to use it within my dialog (i want to try dialog framework, rather than wizard framework).
I just want to have an action "Create MySpace" like "Create Space" in the browse create menu, that launches a dialog like CreateSpaceDialog with more fields to fill.
I have setup the action menu,  the jsp form file, and the CreateMySpaceDialog bean, i wonder if i have to create a custom model that mapps with my new fields? and if yes, how do i do to make sure that the created space is in the same type of my new content type (MySpace and not a standard space)?


Do i have to used the wizard framework, and not the dialog framework to do that?


thanks

gavinc
Champ in-the-making
Champ in-the-making
Yes, you'll need to create a new type in a model and define the extra properties you want, say for this example it's called "custom:myspace" and the properties are "custom:fieldOne" and "custom:fieldTwo".

You'll need to extend the CreateSpaceDialog class and override the init and finishImpl methods.

In the init method set the "this.spaceType" member variable to be the QName of the custom i.e. "custom:myspace".

In the finishImpl method, call the super class version and then using the this.createdNode member variable set the other properties i.e. "custom:fieldOne" and "custom:fieldTwo". This would look something like:

You'll then need to add some config to show these new properties in the property sheet by adding the following to web-client-config-custom.xml:

<config evaluator="node-type" condition="custom:myspace">
   <property-sheet>
      <show-property name="name"/>
      <show-property name="title"/>
      <show-property name="custom:fieldOne" />
      <show-property name="custom:fieldOne" />
   </property-sheet>
</config>

Hope that helps!

alpha
Champ in-the-making
Champ in-the-making
thanks for the hint!
i think there is something missing in your post, when u say :
In the finishImpl method, call the super class version and then using the this.createdNode member variable set the other properties i.e. "custom:fieldOne" and "custom:fieldTwo". This would look something like:

thanks

gavinc
Champ in-the-making
Champ in-the-making
Yes, you're quite right, the missing code would look something like:


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

   this.nodeService.setProperty(this.createdNode, <QName for custom:fieldOne>, value);
   this.nodeService.setProperty(this.createdNode, <QName for custom:fieldTwo>, value);

   return outcome;
}

alpha
Champ in-the-making
Champ in-the-making
thanks, it works fine!
I had first tried this code :

super.finishImpl(context,outcome);

Map<QName, Serializable> props = new HashMap<QName, Serializable>(3);
props.put(<QName for custom:fieldOne>, value);
props.put(<QName for custom:fieldTwo>, value);
this.nodeService.setProperties(this.createdNode, props);

return outcome;

but it didn't work, the integritychecker was yelling that mandatory fields creator and created were not set…weird isn't it.

i don't really know why i had this error  :cry:

but it's working with your hint!

thanks

gavinc
Champ in-the-making
Champ in-the-making
It's because when you call setProperties (as opposed to setProperty) you are replacing ALL properties on the node, you therefore have to supply any mandatory properties in your hash map.

If you really want to use setProperties you'd first have to retrieve all the properties using nodeService.getProperties() and then add your properties to that hashmap and pass it back to setProperties().

What you have now is probably better as you are only setting the properties you need to. The technique above is better when you are setting several properties (it can save you making several separate setProperty calls).

Hope that makes sense!

alpha
Champ in-the-making
Champ in-the-making
this definetly makes sense! Alfresco is cool… 😎