0 Replies Latest reply on Feb 4, 2013 11:03 AM by vomi

    Data iteration : duplicate a row

    vomi Newbie

      Dear all,

       

      This might be a stupid problem, but I can't find the problem here.

      I have a simple dataTable iterating through a list of projects.

      For each project I have a link to view, edit or duplicate it.

      The 2 first actions work well, but I can't duplicate a project because the ProjectHome.getInstance() method won't work since there is no view in the s:link tag. (i.e. : one work around is to assign a view to the s:link tag,  but I do not want that).

       

      So my question is : why does the home.getInstance() does not work ? It will work on a project if I previously edited this particular project. However, if I edit project 1, and I click duplicate for project 2, project 1 is duplicated.

       

      I think the answer is as stupid as I am ... but

       

      Thanks for the help

       

      [code]

      <ui:param name="project" value="#{listProjects}" />

        <rich:dataTable id="projectTable"

        onRowMouseOver="this.style.backgroundColor='#F1F1F1'"

        onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"

        cellpadding="0" cellspacing="0" width="100%" border="0" var="project" value="#{listProjects}">

        <f:facet name="header">

                                    <h:outputText>Project name : #{project.name}</h:outputText>

        </f:facet>

       

      <rich:column styleClass="pictoCell">

                                    <f:facet name="header">Actions :</f:facet>

        <s:link view="/s/projects/view2.xhtml" action="#{projectCtrl2.view}">

        <f:param name="aId" value="#{project.id}"/>

        <f:param name="clId" value="#{project.client.id}"/>

        <img alt="view" src="/img/pictoloupe.png" class="pictoButton"/>

        </s:link>

        <s:link view="/s/projects/edit2.xhtml" action="#{projectCtrl2.edit}">

        <f:param name="aId" value="#{project.id}"/>

        <f:param name="clId" value="#{project.client.id}"/>

        <img alt="edit" src="/img/pictocrayon.png" class="pictoButton"/>

        </s:link>

        <s:link action="#{projectCtrl2.duplicateProject}">

        <f:param name="aId" value="#{project.id}"/>

        <f:param name="clId" value="#{project.client.id}"/>

                                              Duplicate

        </s:link>

        </rich:column>

      [/code]

       

      ProjectCtrl2 :

      [code]

      @Begin(flushMode=FlushModeType.MANUAL, join=true)

                public void view() {

                          home.getInstance();

                }

                @Begin(flushMode=FlushModeType.MANUAL, join=true)

                public void newProject() {

        logger.info("New project... ");

                          home.clearInstance();

                          home.getInstance();

                }

                @Begin(flushMode=FlushModeType.MANUAL, join=true)

                public void duplicateProject() {

        logger.info("Duplicating project ...");

                          logger.info("Current project id = #0", home.getInstance().getId());

                          NewProject copy = home.getInstance();

                          logger.info("Copy project id = #0", copy.getId());

                          NewProject pj = new NewProject();

                          pj.setClient(copy.getClient());

                          pj.setCreationDate(copy.getCreationDate());

      [/code]