4 Replies Latest reply on Jun 13, 2007 7:16 AM by mvlach

    Update example: how to do ?

    mvlach

      How to create edit action ? I am using the page parameter and call method load (in edit.page.xml file). But when push Update button the viewArtcile doesn't contain all of the loaded attributes. The Account is not set for example....

      How to create update action ?

      Thanks Mila


      @Name("articleEditAction")
      public class ArticleEditAction {
      
       @In
       Session ses;
      
       @In
       ViewArticle viewArticle;
      
       @Logger
       Log log;
      
       @In(create = true)
       Configuration configuration;
      
       @End
       public String save() {
       log.info("saving the article: #0", viewArticle);
      
      // article doesn't contains all attributes loaded in method load()
       ses.update(viewArticle);
      
      
       return "success";
       }
      
       @Begin
       public String load(Long id) {
       viewArticle = (ViewArticle) ses.load(ViewArticle.class, id);
       log.info("loaded article for edit: #0", viewArticle);
       return null;
       }
      
       @Remove
       @Destroy
       public void remove() {
       log.info("deleting object articleEditAction");
       }
      


        • 1. Re: Update example: how to do ?
          pmuir

          Post the JSF and and the .page.xml as well.

          • 2. Re: Update example: how to do ?
            mvlach

            I don't understand...

            • 3. Re: Update example: how to do ?
              pmuir

              Post [1] the JSF [2] page and the .page.xml [3]

              [1] to place text on a Web site.

              [2] http://en.wikipedia.org/wiki/JavaServer_Faces

              [3] http://docs.jboss.com/seam/1.2.1.GA/reference/en/html/events.html#d0e3946

              • 4. Re: Update example: how to do ?
                mvlach

                 

                 <h:form>
                 <fieldset>
                 <legend><h:outputText value="#{messages['zakladni.informace']}" /></legend>
                 <table class="full">
                 <tr>
                 <td colspan="2">
                 <table class="full">
                 <tr>
                 <td>obrazek1</td>
                 <td>anotacni text</td>
                 <td>obrazek2</td>
                 </tr>
                 </table>
                 </td>
                 </tr>
                 <s:decorate template="/edit.xhtml">
                 <ui:define name="label"><h:outputText value="#{messages['author.name']}" />:</ui:define>
                 <h:inputText value="#{viewArticle.authorName}" />
                 </s:decorate>
                 <s:decorate template="/edit.xhtml">
                 <ui:define name="label"><h:outputText value="#{messages['article.title']}" />:</ui:define>
                 <h:inputText value="#{viewArticle.title}" />
                 </s:decorate>
                 <tr>
                 <th>Ikonky</th>
                 <td>nejake ikonkty</td>
                 </tr>
                 <s:decorate template="/edit.xhtml">
                 <ui:define name="label"><h:outputText value="#{messages['intro.text']}" /></ui:define>
                 <h:inputTextarea value="#{viewArticle.introText}" />
                 </s:decorate>
                 <s:decorate template="/edit.xhtml">
                 <ui:define name="label"><h:outputText value="#{messages['full.text']}" /></ui:define>
                 <h:inputTextarea value="#{viewArticle.fullText}" />
                 </s:decorate>
                 <s:decorate template="/edit.xhtml">
                 <ui:define name="label"><h:outputText value="#{messages['article.keywords']}" />:</ui:define>
                 <h:inputText value="#{viewArticle.keywords}" />
                 </s:decorate>
                 <s:decorate template="/edit.xhtml">
                 <ui:define name="label"><h:outputText value="#{messages['article.description']}" />:</ui:define>
                 <h:inputText value="#{viewArticle.descriptions}" />
                 </s:decorate>
                 <s:decorate template="/edit.xhtml">
                 <ui:define name="label"><h:outputText value="#{messages['article.links']}" />:</ui:define>
                 <h:inputTextarea value="#{viewArticle.links}" />
                 </s:decorate>
                
                 <s:decorate template="/edit.xhtml">
                 <ui:define name="label"><h:outputText value="#{messages['article.gallery']}" />:</ui:define>
                 <h:selectOneMenu value="#{viewArticle.galleryId}">
                 <f:selectItems value="#{galleryComboAction.galleries}" />
                 </h:selectOneMenu>
                 </s:decorate>
                 <tr>
                 <td colspan="2">
                 <h:commandButton value="Upravit" action="#{articleEditAction.save}" />
                 </td>
                 </tr>
                 </table>
                 </fieldset>
                 </h:form>
                


                <?xml version="1.0" encoding="UTF-8"?>
                <!-- incident view - action execute before show -->
                <page view-id="/admin/actions/article/articleedit.xhtml">
                 <param name="id" value="#{article.id}" />
                 <action execute="#{articleEditAction.load(article.id)}" />
                </page>