sounds like a detached object. the interesting part would be where you got
the object from. if you're using OpensessionInViewFilter (and therefore a
session is during the whole request), it's likely that the object stays in
the session between requests - you should use LoadableDetachableModels then
...



Steve Olara wrote:
> 
> Hello All,
>  
> I have been trying to design functionality of a webapp using wizard.
>  
> I need to pass a object (Questionnaire) to the wizard page, the object
> contains a set of questions.
>  
> on passing the object, when I try to pick the set of questions using
> q.getqn() where q is the object, a null set is returned and I get a error
> saying: LazyInitializationException:19 - failed to lazily initialize a
> collection of role: questionnaire.model.Questionnaire.qn, no session or
> session was closed
> 
> I have searched and found lots of articles about this error but I guess my
> programming is still imature cause I seem not to get this to work yet.
>  
> Below is my code is there a way of passing the previous session to this
> class.
> 
>  
> public final class AnswerWizard extends Wizard {
>     public AnswerWizard(String id, Questionnaire q) {
>         super(id);
>         
>         // create a model with a couple of custom panels
>         // still not that spectacular, but at least it
>         // will give you a hint of how nice it is to
>         // be able to work with custom panels
>         WizardModel model = new WizardModel();
>        
>         Set questions = q.getQn();
>       
>         Iterator iter = questions.iterator();
>         System.out.println("Testing55: " );
>         for (;iter.hasNext();) {
>             Question qn = (Question) iter.next();
>             if (qn instanceof QuestionShortAns) {
>                 model.add(new StepQSA((QuestionShortAns) qn));
>             } else if (qn instanceof QuestionSingleSelect) {
>                 model.add(new StepQSS((QuestionSingleSelect) qn));
>             } else if (qn instanceof QuestionMatch) {
>                 model.add(new StepQm((QuestionMatch) qn));
>             }
>         }
>         // initialize the wizard
>         init(model);
>     }
>     private static final class StepQSS extends WizardStep {
>         /**
>          * Construct.
>          */
>         public StepQSS(QuestionSingleSelect qn) {
>             super("One", "The first step");
>         }
>     }
>     private static final class StepQSA extends WizardStep {
>         /**
>          * Construct.
>          */
>         public StepQSA(QuestionShortAns qn) {
>             super("Two", "The second step");
>         }
>     }
>     private static final class StepQm extends WizardStep {
>         /**
>          * Construct.
>          */
>         public StepQm(QuestionMatch qn) {
>             super("Three", "The third step");
>         }
>     }
>     public void onCancel() {
>         //setResponsePage(Index.class);
>     }
>     /**
>      * @see org.apache.wicket.extensions.wizard.Wizard#onFinish()
>      */
>     public void onFinish() {
>         // setResponsePage(Index.class);
>     }
> }
> 
>  
> Any Help will be highly appreciated
> 
>  
> 
> 
> 
> 


-----
Michael Sparer
http://techblog.molindo.at
-- 
View this message in context: 
http://www.nabble.com/Re%3A-passing-a-session-to-a-wizard-tp24569201p24572534.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to