Once you forwarded the user, use the defaults and options to
maintain the data and turn fields on and off. If you use
FunFormKit then you can do the following:
When a form is sent sucesfully -
self.session().setValue('CurrentQ',fields)
When you render the next form:
if (self.session().hasValue('CurrentQ')):
defaults = self.session().value('CurrentQ')
This will maintain any values that match.
OR (using Fun Form Kit)
Rather then have the servlet generate the form directly you can
also put some logic into the servlet first to determine what form
to show.
In the snip attached I do the following-
1) If there is a session varaible called 'CurrentQ' then pull
the values from that variable and use thoes to generate a form.
When the user sucessfully sends the form I call
self.session().setValue('CurrentQ',fields) to set this value.
This way the user will always see the form as (s)he last used it.
2) If the user clicked on the 'clear' button then I run clearForm
and set the defaults to null and generate the form
3) If the user clicked 'load favorite' then I pull some fields
from a database and use them as defaults.
You could easily extent this code to change options and make
certain fields hidden but beware the select box. I tried to make
a slick DHTML multi-form on one page but when I hid the select
box FFK returned an error becuase it checks that the value of a
select matches one of the options. When I hid the select I also
'disabled' it in DHTML and then browser did not send that
variable.
def writeForm(self):
defaults = {}
options = {}
if (self.session().hasValue('CurrentQ')):
defaults = self.session().value('CurrentQ')
self.genForm(defaults,options)
self.setUpLog('BasicQ','%s views a blank form' %
self._user.name)
def clearForm(self,fields):
''' Clear the Defaults and pass to genForm'''
defaults = {}
options = {}
self.genForm(defaults,options)
self.setUpLog('BasicQ-Clear','%s clears the form' %
self._user.name)
def loadQ(self,fields):
''' Load the saved defaults from the database and pass to
genForm'''
defaults =
FavManager.getFav(self.session().value('user'),fields['LoadQ'])
print "************"
print
FavManager.getFav(self.session().value('user'),fields['LoadQ'])
print "************"
options = {}
self.genForm(defaults,options)
self.setUpLog('BasicQ-LoadQ','%s loads favorite %s' %
(self._user.name,fields['LoadQ']))
def genForm(self,defaults,options,msg=''):
'''Display the actual form to the user'''
options["LoadQ"] =
{'selections':FavManager.getFavList(self.session().value('user'))
}
rf = self.renderableForm(defaults=default........
<<<SNIP>>>
-Aaron Held
----- Original Message -----
From: "Jason Hildebrand" <[EMAIL PROTECTED]>
To: "'Frank St�ss'" <[EMAIL PROTECTED]>
Cc: "webware-discuss" <[EMAIL PROTECTED]>
Sent: Wednesday, January 30, 2002 2:54 PM
Subject: RE: [Webware-discuss] State-machine servlets
> On Wed, 2002-01-30 at 13:52, Geoffrey Talvola wrote:
>
> > > Best way for me was subclassing an abstract class, but i
even
> > > don't know
> > > how to call another servlet.
> >
> > You can call another servlet using
> >
> > self.application().forward(self.transaction(),
'NameOfServlet')
> >
> > or if you're using a recent snapshot from CVS, you can just
write:
> >
> > self.forward('NameOfServlet')
>
> If on the other hand you'd like the user's browser to jump from
> the current servlet to a different one (i.e. you want to
process
> the results of a form and go to either X or Y depending on the
> result, you can send an HTTP redirect:
>
> self.response().sendRedirect("ServletX")
>
> Although IIRC redirects are supposed to be fully qualified
(absolute)
> URIs (you could write yourself a wrapper function to qualify
> relative addresses).
>
> Hope this helps,
> Jason
>
>
> _______________________________________________
> Webware-discuss mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/webware-discuss
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss