Hi Gonzalo, I thought that with buildForm implementation I will see how you
create your form component. But seams that it is created on the line:
QuestionComponentFactory.getComponent(question,response)

Instead of ask you for more code, I will try to explain myself:

>So no matter what's the value it will get not updated to the new one.
Any build component logic will stop you from create an form with an dynamic
model on it. I thing you are updating an object instance that isn't the one
on your form model.
on lines:
                        response = surveyAnswerFactory.getResponse(question,
answer);
and then:


categoryComponent.add(QuestionComponentFactory.getComponent(question,
                                response));
be sure of to work on the same response instance that is on your form model.

On Tue, Nov 3, 2009 at 1:38 PM, Gonzalo Aguilar Delgado <
gagui...@aguilardelgado.com> wrote:

>
>
>
> > >I should build the form inside a component instead the page. And I
> > >should keep a reference
> > >to the dynamic model inside this component.
> > Not what I try to mean.
>
>
> So what's the way?
>
>
>
> >
> > your report:
> > >But as I have to build the form I do not have a dynamic model on page.
> > You can have your model, and you can have your component build logic.
>
>
> mmmm
>
>
> >
> > you report:
> >
> > >So no matter what's the value it will get not updated to
> > >the new one.
> > so i think you are working on diferent answer instances
> > can you send some buildForm(answer) lines?
>
>
> Yes but's somewhat large, anyway answer has got from the code I sent
> earlier. But it got not
> updated because this code goes in the constructor that never gets
> called.
>
> Here goes the code:
>
>
>        public void buildForm(SurveyAnswer answer)
>        {
>
>                List<SurveyQuestion> listQuestions = getQuestionList(1); //
> FIXIT: How
> do we get this questionaire?
>
>                if(listQuestions!=null && listQuestions.size()>0)
>                {
>
>                        int category = -1;
>                        QuestionCategoryComponent categoryComponent = null;
>
>                        /*
>                         * We add category containers to the component array
> and
>                         * questions to the category containers.
>                         *
>                         */
>                        for(Iterator<SurveyQuestion> iter =
> listQuestions.iterator();
> iter.hasNext();)
>                        {
>                                SurveyQuestion question = iter.next();
>
>                                // Check if we should start a new category
>                                if(category !=
> question.getSurveyQuestionCategory().getIdSurveyQuestionCategory())
>                                {
>                                        log.debug("Category: " +
> question.getSurveyQuestionCategory().getQuestionCategoryDescription());
>                                        categoryComponent = new
> QuestionCategoryComponent("surveyComponent",
> question.getSurveyQuestionCategory().getQuestionCategoryDescription());
>                                        components.add(categoryComponent);
>                                        category =
> question.getSurveyQuestionCategory().getIdSurveyQuestionCategory();
>                                }
>
>                                if(categoryComponent!=null)
>                                {
>                                        SurveyQuestionResponse response =
> null;
>                                        if(answer!=null)
>                                        {
>                                                response =
> surveyAnswerFactory.getResponse(question, answer);
>
>  if(response.getIdSurveyQuestionResponse()==null)
>                                                {
>                                                        log.info("Creating
> a new answer for this question");
>
>
>  surveyQuestionResponseDAO.save(response);
>
>                                                }
>                                        }
>
>                                        // Each question component holds
> question and answer
>                                        try {
>
> categoryComponent.add(QuestionComponentFactory.getComponent(question,
> response));
>                                        } catch (ComponentTypeException e) {
>                                                try {
>                                                        warn("Response for
> question: " +
> question.getSurveyQuestionDescription() + " has incorrect response!");
>
> categoryComponent.add(QuestionComponentFactory.getComponent(question));
>                                                } catch
> (ComponentTypeException e1) {
>                                                        log.error("Cannot
> create component");
>                                                }
>                                        }
>                                }
>
>
>                        }
>
>                }
>        }
>
>
> >
>



-- 
Pedro Henrique Oliveira dos Santos

Reply via email to