4 Replies Latest reply on Jan 9, 2008 7:40 PM by pmuir

    Edit details

    vikramchhetryy

      Hi All,
      I have two associated tables viz. User and LoginInfo .
      User table contains:-
      UserId
      FirstName
      UserType

      LoginInfo table contains:-
      UserId
      UserName
      Password

      I have 2 type of users: Admin and Agent
      Admin can search agents and change Agent details(FirstName, UserName, Password).
      I have search result page with edit link in front on every agent.
      I dont know how to pre populate the edit form and update the changes in the database.

      Can anyone just give me an idea how to do this.

      Any help would be appreciated.

      Regards,
      Vikram

        • 1. Re: Edit details
          vikramchhetryy

          Hi,
          Why anyone doesnt answer me? Am I in a wrong forum? I nearly have 10 unanswered posts.
          Anyways I tried to solve it and wrote some doce for this.

          XHTML:-

          <a:outputPanel id="searchResults">
           <div class="section"><h:outputText value="No Agents Found"
           rendered="#{agentDetails != null and agentDetails.rowCount==0}" />
           <h:dataTable id="agentDetails" value="#{agentDetails}"
           var="details" rendered="#{agentDetails.rowCount>0}"
           style="width: 400px;text-align:center;" border="1">
           <h:column>
           <f:facet name="header">
           <f:facet name="header">Unlock ?</f:facet>
           </f:facet>
           <h:selectBooleanCheckbox
           value="#{callCenterAgentManage.selectedAccount[details]}"
           style="height: 15px;" />
           </h:column>
           <h:column>
           <f:facet name="header">User Name</f:facet>
           #{details.strUserName}
           </h:column>
           <h:column>
           <f:facet name="header">First Name</f:facet>
           #{details.person.strFirstName}
           </h:column>
           <h:column>
           <f:facet name="header">Last Name</f:facet>
           #{details.person.strLastName}
           </h:column>
           <h:column>
           <f:facet name="header">Account Status</f:facet>
           #{details.flgAccountStatus}
           </h:column>
           <h:column>
           <f:facet name="header">Action</f:facet>
           <s:link id="editCallCenterAgent" value="Edit"
           action="callCenterAgentManage.editSelectedCallCenterAgentDetails(details)" />
           </h:column>
           </h:dataTable>
           <h:commandButton
           action="#{callCenterAgentManage.unlockSelectedCallCenterAgentAccount}"
           value="Activate Agent" />
           </a:outputPanel>



          Inside Java:
           @Begin
           public void editSelectedCallCenterAgentDetails(Account acc) {
           log.info("Inside editSelectedCallCenterAgentDetails method "
           + acc.getPerson().getStrFirstName());
           getSelectedCallCenterAgentDetails(acc.getStrUserName());
           log.info("Exiting editSelectedCallCenterAgentDetails method");
           }
          
           public void getSelectedCallCenterAgentDetails(String userName) {
           log.info("Inside getSelectedCallCenterAgentDetails method " + userName);
          
           log.info("Exiting getSelectedCallCenterAgentDetails method");
           }
          
           @End
           public void updateCallCenterAgentDetails() {
           log.info("Inside updateCallCenterAgentDetails method");
          
           log.info("Exiting updateCallCenterAgentDetails method");
           }


          Pages.xml
           <page view-id="/callCenterAgentManage.xhtml"
           login-required="true">
          
           <navigation
           from-action="#{callCenterAgentManage.editSelectedCallCenterAgentDetails(details)}">
           <redirect view-id="/callCenterAgentEdit.xhtml" />
           </navigation>
          
           <navigation from-action="#{callCenterAgentManage.cancel}">
           <redirect view-id="/callCenterAgentManage.xhtml" />
           </navigation>
          
           </page>


          When I click the edit link nothing happens. Nothing is printed in the logs as well.

          Can any one tell me whats going wrong?

          Any would be appreciated.

          Thanks in advance,
          Vikram

          • 2. Re: Edit details
            pmuir

             

            "vikramchhetryy" wrote:
            Hi,
            Why anyone doesnt answer me? Am I in a wrong forum? I nearly have 10 unanswered posts.


            Unfortunately the turnaround here tends to be a few hours not a few minutes.

            Take a look at the examples or a seam-gen'd reverse engineering - they both do this sort of thing.

            In general, asking questions like "How do I write my design my CRUD app" don't get many responses - try asking specific questions.

            • 3. Re: Edit details
              vikramchhetryy

              Thanks for your response pete.

              I tried seam reverse engineering but there is an error in seam generate-ui command
              ERROR:-

              [hibernate] INFO: Hibernate EntityManager 3.3.1.GA
              [hibernate] An exception occurred while running exporter #2:generic exportertemplate: view/list.xhtml.ftl
              [hibernate] To get the full stack trace run ant with -verbose
              [hibernate] Problems in creating a configuration for JPA. Have you remembered to add hibernate EntityManager jars to the classpath ?
              [hibernate] java.lang.reflect.InvocationTargetException
              [hibernate] javax.persistence.PersistenceException: java.lang.TypeNotPresentException: Type org.jboss.seam.annotations.Name not present
              [hibernate] java.lang.TypeNotPresentException: Type org.jboss.seam.annotations.Name not present
              [hibernate] java.lang.ClassNotFoundException: org.jboss.seam.annotations.Name
              [hibernate] A class were not found in the classpath of the Ant task.
              [hibernate] Ensure that the classpath contains the classes needed for Hibernate and your code are in the classpath.
              
              BUILD FAILED
              /home/vikramc/eclipseEuropa/seam/seam-gen/build.xml:1057: Problems in creating a configuration for JPA. Have you remembered to add hibernate EntityManager jars to the classpath ?
              


              I have one more question.
              I have a dropdown populated from the database.
              the value of the option always starts from 0, i want it to be the primary key from the database.

              <s:decorate template="layout/edit.xhtml">
               <ui:define name="label">Favourite Book</ui:define>
               <ui:define name="description">A book has a composite key</ui:define>
               <h:selectOneMenu value="#{roles.iroleId}">
               <s:selectItems value="#{role.resultList}" var="role1" label="#{role1.strDescription}" noSelectionLabel="Please Select."/>
               <s:convertEntity />
               </h:selectOneMenu>
              </s:decorate>


              How do I solve this?

              Thanks in advace.

              • 4. Re: Edit details
                pmuir

                What version of Seam.

                the value of the option always starts from 0, i want it to be the primary key from the database.


                You need to use Seam 2.0.1.CR1 and create your own entityIdentifierStore. This isn't currently documented, so you are on your own (I have about half a blog written on this which I will publish soon).