1 Reply Latest reply on Jun 16, 2010 2:08 AM by shane lee

    Form wizard and conversation scope issue

    shane lee Newbie

      Environment: Seam 2.2.0.GA JDK 1.6 JBOSS 5.1.0.GA Hibernate 3.3.0.GA

      Im having an issue setting up a simple form wizard.
      Steps are:

       * Screen #1: submit inquiry form detail
       * Screen #2: add attachment(s) 
       * Screen #3: confirm attachment list

      Im on screen 2 and when i add attachment to inquiry, they are not been stored. I am using a stateful session bean, which default scope is conversation for my action class.

      I have a radio button on screen one adding inqiry, isAddAttachments. If true then i go to screen two and upload as many attachments as i want before submitting. I outject newInquiry to conversation scope so i take its stored there until i end the conversation. problem is every time i add an attachment the size of the list is one.

      Why is that? Is it a problem around seam component newAttachment or the way im storing my newInquiry context variable?

      Snippet Code for action class is:

      public class InquiryAction implements Inquiry {
          private inquiry.model.Inquiry newInquiry;
          Attachment newAttachment;
          @Logger private Log log;
          private Renderer renderer;
          private EntityManager entityManager;
          private org.jboss.seam.faces.FacesMessages facesMessages;
          public String addInquiry(){
                      //store pdf in document
                      byte[] pdf = this.createPDF();
                          facesMessages.add("Successfully submitted web inquiry form");
                      return "success";
                  facesMessages.add("Email addresses do not match");
                  return null;
          public void save(){
              facesMessages.add("Successfully submitted web inquiry form");
          public void addAttachment(){
              facesMessages.add("Added attachment to inquiry form {0}",newAttachment.getFileName());
          public String cancel(){
              return "/home.xhtml";

      Inquiry entity is:

      @Name(value = "newInquiry")
      public class Inquiry  implements Serializable{
          private static final long serialVersionUID = 1L;
          private long id;
          private String question;
          private String entityNumber;
          private String entityName;
          private Title title;
          private String givenName;
          private String familyName;
          private String telephoneNumber;
          private String email;
          private QuestionType questionType;
          private String timeToCall;
          private String confirmEmail;
          private boolean addAttachments;
          private byte[] pdfDocument;
          private Set<Attachment> attachments = new HashSet<Attachment>(0);
          @AttributeOverrides( {
                  @AttributeOverride(name="countryCode", column = @Column(name="countryCode")) } )
          private Address address = new Address();
          public Inquiry(){
          public long getId() {
              return id;
          public void setId(long id){
              this.id = id;
          @Column(name = "pdfDoc")
          @Basic(fetch = FetchType.LAZY)
          public byte[] getPdfDocument() {
              return pdfDocument;
          public void setPdfDocument(byte[] pdfDocument) {
              this.pdfDocument = pdfDocument;
          public boolean isAddAttachments() {
              return addAttachments;
          public void setAddAttachments(boolean addAttachments) {
              this.addAttachments = addAttachments;
          @Column(nullable = false)
          public String getTimeToCall() {
              return timeToCall;
          public void setTimeToCall(String timeToCall) {
              this.timeToCall = timeToCall;
          public QuestionType getQuestionType() {
              return questionType;
          public void setQuestionType(QuestionType questionType) {
              this.questionType = questionType;
          @Column(length = 5000)
          public String getQuestion() {
              return question;
          public void setQuestion(String question) {
              this.question = question;
          @Column(length = 9, nullable = false)
          public String getEntityNumber() {
              return entityNumber;
          public void setEntityNumber(String entityNumber) {
              this.entityNumber = entityNumber;
          public String getEntityName() {
              return entityName;
          public void setEntityName(String entityName) {
              this.entityName = entityName;
          public Title getTitle() {
              return title;
          public void setTitle(Title title) {
              this.title = title;
          public String getGivenName() {
              return givenName;
          public void setGivenName(String givenName) {
              this.givenName = givenName;
          public String getFamilyName() {
              return familyName;
          public void setFamilyName(String familyName) {
              this.familyName = familyName;
          @Column(name = "phoneNo")
          public String getTelephoneNumber() {
              return telephoneNumber;
          public void setTelephoneNumber(String telephoneNumber) {
              this.telephoneNumber = telephoneNumber;
          public String getEmail() {
              return email;
          public void setEmail(String email) {
              this.email = email;
          public String getConfirmEmail(){
              return this.confirmEmail;
          public void setConfirmEmail(String email) {
              this.confirmEmail = email;
          @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "inquiry")
          public Set<Attachment> getAttachments() {
              return attachments;
          public void setAttachments(Set<Attachment> attachments) {
              this.attachments = attachments;
          public Address getAddress() {
              return address;
          public void setAddress(Address address) {
              this.address = address;

      Attachment screen snippet is:

       <h:form enctype="multipart/form-data" id="attachmentForm" styleClass="edit">
                  <f:facet name="header">General Inquiry form - Attachments</f:facet>
                  <s:decorate id="descField" template="layout/edit.xhtml">
                      <ui:define name="label">Description of Document</ui:define>
                      <h:inputText id="description"
                  <s:decorate id="fileUploadDecoration" template="layout/edit.xhtml">
                               <ui:define name="label">Pathname</ui:define>
                               <s:fileUpload id="file" 
                                          fileSize="#{newAttachment.fileSize}" />
                           <div style="clear:both">
                      <span class="required">*</span>
                      required fields
                  <div class="actionButtons">
                          <h:commandButton value="Upload" 
                          <h:commandButton value="Next" 
                     <s:link view="/attachmentList.xhtml" value="Attachment Summary"/>