Tags:
create new tag
view all tags

Question

I am writing a plug-in(Using REST) to show a form to the user and and posting the values to the database.After the data is posted to the database, a confirmation page is shown to the user that looks like this

"Your request has been submitted. Your request number is xxxx.

Click here to go back to the page you were viewing."

If the database post fails show a suitable error text.

I am thinking of couple of ways to do this.

  1. Func::redirectCGIQuery(): I will pump in the confirmation number, original URL, error text(if present) to the cgi parameters. This does not seem like good option as the data I want to pass is sometimes long text.
  2. Session Variables: I will store the data into session variables, load the confirmation topic (using $session{store}->readTopic() ). The confirmation topic then will reference those variables using %SESSION_VARIABLE{"name"} to display the confirmation text. In the same topic we will also say %SESSION_VARIABLE{"name" clear=""} to delete the session variable as we will not need it in future requests. This is a long-drawn process but I am unable to find a better way.

Is there any other way to pass variables calcuated in the plug-in to a template other than using Session variables ? How to store values in a request scope object and read it in the topic.

Basically what I am getting at is, is it possible to implement MVC architecture using Twiki plugins, so that we can separate presentation and business logic when writing plug-ins ( business and controller logic goes into the plug-in code and the presentation will be thru a topic)? If I show the output thru the Plug-In itself, I have to write lots of Print systems.

I will really appreciate if someone can guide me in the right direction.

Environment

TWiki version: TWikiRelease04x02x01
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Windows 2003 Server
Web server: Apache 2.2
Perl version:  
Client OS:  
Web Browser:  
Categories: Plugins

-- KotiReddy - 18 Aug 2008

Answer

ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

I don't know if this is any help, but I have achieved the same thing using the DBIQueryPlugin

I have a topic containing a web-form whose action is to view another topic containing a block of DBI_DO code to save the form details to the database. This second topic then displays confirmation of the database save.

Is that what you wanted to do?

-- DuncanKinnear - 01 Sep 2008

I updated the question and added some more clarity

-- KotiReddy - 03 Sep 2008

You could use a template to store the fixed data, fill up the info you need and return the complete text as the result of your rest method.

Check out MailerContrib to see how it uses templates to build the email. The function to read templates is TWiki::Func::readTemplate. Also remember that templates can be topics. I know this is cryptic, they are just pointers. Leaving the office now.

-- RafaelAlvarez - 04 Sep 2008

I have gone thru MailerContrib. So the REST program it is basically doing a regex 'match and replace' of the variables inside the template. Will this impact performance ? OR is it just the way Twiki does variable interpretation. So even if is use %SESSION_VARIABLE{".."}, the same thing happens when Twiki processes that topic ?

-- KotiReddy - 10 Sep 2008

Sorry, closing after more than 30 days. Please reopen with more details if needed...

-- PeterThoeny - 06 Nov 2008

Change status to:
Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2008-11-06 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.