Announcement Announcement Module
Collapse
No announcement yet.
Editing user information Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Editing user information

    Dear all;

    I am editing the user information with it address info using two tables: - User and Addresses which has been mapping with one to many relationship using hibernate JPA.

    Problem: while editing address info firstly, I need to keep it all input addresses in List, after that, when all the input addresses is obtained then I do the both insertion and update operation for the existing data as well as new added address data with the whole user information.

    What is best approaches to solve this issue?

    Highly appreciate for the good solution for this issue using spring webflow.

    Jsp code:
    --------------------------------------------------------------------------------------------------------------------------------------------
    <form:form method="post" modelAttribute="registrationModel">

    <fieldset><legend> Kontaktdaten </legend>
    <ol>
    <li><label for="firstname">Name: <form:errors
    path="firstname" cssClass="error" /> </label> <form:input path="firstname" cssClass="text" /> <span
    class="requiredstar">*</span></li>
    <li><label for="lastname">Vorname: <form:errors
    path="lastname" cssClass="error" /> </label> <form:input path="lastname" cssClass="text" /> <span
    class="requiredstar">*</span></li>
    </ol>

    <form:form method="post" modelAttribute="registrationModel">
    <div id="address-list">
    <div class="address-block">
    <ol>
    <li><label for="street">Straße und Hausnummer: <form:errors
    path="street" cssClass="error" /> </label> <form:input path="street" cssClass="text street" /></li>
    <li><label for="postcode">PLZ: <form:errors
    path="postcode" cssClass="error" /> </label> <form:input path="postcode" cssClass="postcode" /></li>
    <li><label for="city">Ort: <form:errors path="city"
    cssClass="error" /> </label> <form:input path="city" cssClass="text city" /></li><br />
    </ol>
    <ol>
    <li><input type="submit" name="_eventId_saveUserAddressData" value="Speichern" class="button" /><input type="button" value="Löschen" class="button" onclick="removeAddr(this)" /></li>
    </ol>
    </div>
    </div>
    </form:form>
    <ol>
    <li><input type="button" value="Add" onclick="addAddr()" /></li>
    </ol>

    <ol>
    <li><label for="identitycardnumber">Personalausweis-Nr.: <!-- form:errors path="identitycardnumber"
    cssClass="error" /> --> </label> <form:input path="identitycardnumber" cssClass="text" /></li>
    </ol>
    <ol>
    <li><label for="email"> E-Mail-Adresse: <form:errors path="email"
    cssClass="error" /> </label> <form:input path="email" cssClass="text" /> <span class="requiredstar">*</span><span class="inputinfo">z.B. [email protected]</span></li>
    <li><label for="mobileNumber"><spring:message code="newaccount.personaldata.mobilenumber" /><form:errors path="mobileNumber" cssClass="error" /></label>
    <form:input path="mobileNumber" cssClass="text" /> <span class="requiredstar">*</span><span class="inputinfo">z.B. 0123-12345678</span>
    </li>
    <li><label><spring:message code="newaccount.personaldata.mobileprovider" /></label>
    <form:select path="mobileProvider">
    <form:option value="---" label="-- Anbieter --" />
    <form:option value="Base" label="Base" />
    <form:option value="Blau" label="blau" />
    <form:option value="Debitel" label="Debitel" />
    <form:option value="Debitel light" label="Debitel light" />
    <form:option value="E-plus" label="E-plus" />
    <form:option value="Klarmobil" label="Klarmobil" />
    <form:option value="Mobilcom" label="Mobilcom" />
    <form:option value="O2" label="O2" />
    <form:option value="Phonehouse" label="Phonehouse" />
    <form:option value="Simply" label="Simply" />
    <form:option value="Simyo" label="Simyo" />
    <form:option value="Talkline" label="Talkline" />
    <form:option value="T-Mobile" label="T-Mobile" />
    <form:option value="Vodafone" label="Vodafone" />
    </form:select>
    </li>
    </ol>
    <ol>
    <li><label for="gender">Geschlecht: </label><form:radiobutton path="gender" value="1" /> männlich <form:radiobutton path="gender" value="2" /> weiblich </li>
    <li><label for="smoker">Raucher: </label><form:radiobutton path="smoker" value="0" /> nein <form:radiobutton path="smoker" value="1" /> gelegentlich <form:radiobutton path="smoker" value="2" /> ja </li>
    </ol>
    </fieldset>

    <fieldset><legend> Zustimmungsrelevante Daten </legend>

    <h4>Erhebung von Standort-Daten:</h4>

    <p style="padding: 0.8em 1.2em; border:1px solid grey; font-size:0.9em;">
    Allgemeine Bestimmungen zur Lokalisierung des Benutzers... <br />(siehe AGBs der LBS-Anbieter)
    Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
    sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem
    ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore
    magna aliquyam erat, sed diam voluptua. <br />
    At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
    </p>

    <ol>
    <li class="checkboxradio"><form:checkbox path="agreelocalisation" /> Ja, die Firma Media4U darf meine Standortdaten zu Vermittlungszwecken verwenden.<br />
    <span class="red small">Wichtiger Hinweis: eine (personenbezogene) Ortung findet ausschließlich NUR während des Vermittlungsprozesses statt!</span></li>
    </ol>


    <h4>Weitergabe Ihrer Rufnummer:</h4>
    <ol>
    <li class="checkboxradio"><form:radiobutton path="agreeshowphonenumber" value="0" cssClass="checkboxradio" /><label class="checkboxradio">Ja, meine Rufnummer darf von der Firma an den vermittelten Partner weitergegeben werden.</label></li>
    <li class="checkboxradio"><form:radiobutton path="agreeshowphonenumber" value="1" cssClass="checkboxradio" /><label class="checkboxradio">Ja, meine Rufnummer darf weitergegeben werden, wenn beide Parteien nicht zusammenfinden.</label></li>
    <li class="checkboxradio"><form:radiobutton path="agreeshowphonenumber" value="2" cssClass="checkboxradio" /><label class="checkboxradio">Nein, meine Rufnummer darf in keinem Fall weitergegeben werden.</label></li>
    </ol>
    <p>Rufnummer weitergeben: Was bedeutet das? <a href="">Hilfetext</a></p>
    </fieldset>
    <input type="submit" name="_eventId_saveData" value="Speichern" class="submit"/>

    -------------------------------------------------------------------------------------------------------------------------------------
    flow.xml:-

    <flow xmlns="http://www.springframework.org/schema/webflow"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/webflow
    http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">

    <secured attributes="ROLE_USER,ROLE_PREMIUM" />

    <persistence-context />

    <var name="myAccount" class="mmv.pojos.User" />
    <var name="useraddress" class="mmv.pojos.Useraddress" />
    <var name="registrationModel" class="mmv.pojos.RegistrationModel"/>
    <var name="FileUploadAction" class="mmv.web.handler.FileUploadAction" />
    <var name="fileUploadHandler" class="mmv.web.handler.FileUploadHandler" />

    <on-start>
    <evaluate expression="userService.getUserIdByUsername(curren tUser.name)" result="flowScope.userId" />
    <evaluate expression="userService.getUserById(flowScope.user Id)" result="registrationModel" />
    </on-start>

    <view-state id="MymmvMandatoryData">
    <transition on="change" to="Mymmvmandatorydatachange" />
    <transition on="uploadPicture" to="UploadPicture" />
    </view-state>

    <view-state id="Mymmvmandatorydatachange" model="registrationModel">
    <transition on="saveUserAddressData" to="addAddressList" />
    <transition on="saveData" to="MymmvMandatoryDataChange" />
    </view-state>

    <view-state id="UploadPicture">
    <transition on="upload" to="UploadFileAction"/>
    </view-state>

    <subflow-state id="addAddressList" subflow="createAddress">
    <transition on="addressCreated" to="Mymmvmandatorydatachange">
    <evaluate .......................????????
    </transition>
    </subflow-state>

    <action-state id="MymmvMandatoryDataChange">
    <!-- evaluate expression="userService.persistUser(registrationMo del)" /> -->
    <evaluate expression="userService.persistRegistrationInforma tionEdit(registrationModel)" />
    <transition on="success" to="MymmvMandatoryDataChangeEnd">
    <set name="flashScope.saveDataSuccess" value="true"/>
    </transition>
    <transition on="error" to="MymmvMandatoryDataChangeEnd" />
    </action-state>

    <action-state id="UploadFileAction">
    <evaluate expression="FileUploadAction.doExecute(flowRequest Context)" />
    <transition on="success" to="UploadPicture">
    <!-- <evaluate expression="fileUploadHandler.processFile(flowRequ estContext, myAccount)" /> -->
    <set name="flowScope.fileUploaded" value="true"/>
    </transition>
    <transition on="error" to="UploadPicture"/>
    </action-state>

    <end-state id="MymmvMandatoryDataChangeEnd" commit="true" view="MymmvMandatoryData" />

    </flow>
    -----------------------------------------------------------------------------------------------------------------------------------------------------------
    Note:- I use registrationModel for both user and address attributes, but finally I have to bind there corresponding data to their Corresponding Entity class before doing commit on DB.
    Last edited by japs; Jul 8th, 2011, 04:29 AM.
Working...
X