adding a value to an existing multi value String Property

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

adding a value to an existing multi value String Property

Dev Vale
Hello,

I am currently developing a Marketing Module (somewhat similar to what Reedge.com is doing) for Hippo as an internship project.
I am very new to hippo CMS (and the entire Repository concept) so I am taking things a bit slow.

However I have come to the point where I have created my hippoecm.extension.xml
Which should create a new section to the navigator. There is just one part that needs editing that is the:

/hippo:configuration/hippo:frontend/cms/cms-browser/navigator

I would like to add a value to the already existing: "section: property
AND
I would also like to add a new property in the same node.
However everything I have tried so far (regarding the system view method) have failed..
I know there is an option to use: hippo:contentdelete, to delete the entire node and then recreate it with all the values needed.

However the module I am making should be stand alone and be able to be used by people whom already have existing projects running (that may have added sections as well).

So my question is:
How do I add a value to an already existing Node's property and also add a property to an already existing node (if possible with system view method)

PS: I have also tried making a Java Class that would add the values to the existing node however I don't know how I can get Hippo CMS to load that Java Class during start up/deployment.
The code written for that Java Class is:

public class MMConfigaddNavigatorsection {

public static void main(String[] args) {
        Session session;
        HippoRepository repository;
        try {
            repository = HippoRepositoryFactory.getHippoRepository("rmi://localhost:1099/hipporepository");
            session = repository.login("xxxxx", "xxxxx".toCharArray());
           
            String NavigorPath = "/hippo:configuration/hippo:frontend/cms/cms-browser/navigator";
            String addValue = "section.configsection";
            HippoNode section = (HippoNode) session.getItem(NavigorPath);
            section.setProperty("section.configsection", "service.browse.tree.configsection");
            Property newSection2 = section.getProperty("section");
            newSection2.setValue(addValue);
            session.save();


           
        } catch (RepositoryException e) {
    }



}

I am not sure wether the setValue method...adds a value or resets the entire property and only adds the value I specified.

Thanx in advance

Reply | Threaded
Open this post in threaded view
|

Re: adding a value to an existing multi value String Property

Frank van Lankvelt
yeah, I'm afraid that using contentdelete is the only option to add a
section to the navigator during initialization.  So projects that use
your plugin will have to do the same if they are using other plugins
with their own sections too.

With regards to your question, you should use the setValues methods on
Property.  You can either use String[] or Value[]; to create an
instance of Value, you are advised to use the ValueFactory
(Session#getValueFactory).

Since you're creating a plugin out of this, you could consider turning
it into a forge project?  Seems to be something that could be of
interest to a lot of people.

cheers, Frank


On Thu, May 27, 2010 at 11:23 AM, Dev Vale <[hidden email]> wrote:

>
> Hello,
>
> I am currently developing a Marketing Module (somewhat similar to what
> Reedge.com is doing) for Hippo as an internship project.
> I am very new to hippo CMS (and the entire Repository concept) so I am
> taking things a bit slow.
>
> However I have come to the point where I have created my
> hippoecm.extension.xml
> Which should create a new section to the navigator. There is just one part
> that needs editing that is the:
>
> /hippo:configuration/hippo:frontend/cms/cms-browser/navigator
>
> I would like to add a value to the already existing: "section: property
> AND
> I would also like to add a new property in the same node.
> However everything I have tried so far (regarding the system view method)
> have failed..
> I know there is an option to use: hippo:contentdelete, to delete the entire
> node and then recreate it with all the values needed.
>
> However the module I am making should be stand alone and be able to be used
> by people whom already have existing projects running (that may have added
> sections as well).
>
> So my question is:
> How do I add a value to an already existing Node's property and also add a
> property to an already existing node (if possible with system view method)
>
> PS: I have also tried making a Java Class that would add the values to the
> existing node however I don't know how I can get Hippo CMS to load that Java
> Class during start up/deployment.
> The code written for that Java Class is:
>
> public class MMConfigaddNavigatorsection {
>
> public static void main(String[] args) {
>        Session session;
>        HippoRepository repository;
>        try {
>            repository =
> HippoRepositoryFactory.getHippoRepository("rmi://localhost:1099/hipporepository");
>            session = repository.login("xxxxx", "xxxxx".toCharArray());
>
>            String NavigorPath =
> "/hippo:configuration/hippo:frontend/cms/cms-browser/navigator";
>            String addValue = "section.configsection";
>            HippoNode section = (HippoNode) session.getItem(NavigorPath);
>            section.setProperty("section.configsection",
> "service.browse.tree.configsection");
>            Property newSection2 = section.getProperty("section");
>            newSection2.setValue(addValue);
>            session.save();
>
>
>
>        } catch (RepositoryException e) {
>    }
>
>
>
> }
>
> I am not sure wether the setValue method...adds a value or resets the entire
> property and only adds the value I specified.
>
> Thanx in advance
>
>
> --
> View this message in context: http://hippo.2275632.n2.nabble.com/adding-a-value-to-an-existing-multi-value-String-Property-tp5107724p5107724.html
> Sent from the Plugin Development and Customization mailing list archive at Nabble.com.
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html
>
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: adding a value to an existing multi value String Property

Dev Vale
Hi Frank,

Thank you for the quick and informative response.
I am currently using the hippo:contentdelete option to get me going.

I still have some more questions regarding making your own section in the cms but I will try and figure these out.

Thanks again
Regards


Dev