IOWA Question (long because of code snippets)

B

Ben Schumacher

Hello-

I've been looking through the archives of this list some, but I'm feel
like I'm missing some critical (and probably simple) piece of
information. I'm trying to setup a page in IOWA where the URL contains
some a piece of information needed to render the page.

Basically, I want to take URLs like:

http://localhost:2000/details/FOO/

And have my application render a page using FOO as a variable. My
problem is that I'm using IOWA Webrick and it seems that IOWA is just
passing on processing this. However, if I just go to
http://localhost:2000/details/FOO/, it's working correctly. Maybe I'm
using the mapfile wrong? Or do I just not need the mapfile at all?

My MyApplication class looks like this:

require 'iowa_webrick'

class MyApplication < Iowa::Application
def initialize(*args)
@@cachedSession = 10
@mapfile = 'mapfile.cnf'
super
end
end

Iowa.startDaemon('app.cnf')
Iowa.run

And my Main.iwa looks like (which I found on this list):

class Main < Iowa::Component
def setup
$stderr.puts session.context.request.inspect
asin = File.basename(session.context.request.uri)
dispatch_page = page_named('Details')
dispatch_page.parameter = parameter
dispatch_context = Iowa::Context.new(session.context.request,
session.context.response)
dispatch_context.sessionID = session.context.sessionID
dispatch_context.requestID = session.requestCount
dispatch_page.handleResponse(dispatch_context)
session.currentPage = dispatch_page.dup
end
end

And finally, my mapfile.cnf has:

/: Details
/details: Details
/details/: Details
[
Which is obviously mostly useless, I just was trying a bunch of
different things.

Thanks for your help.

Ben
 
K

Kirk Haines

Hello-

I've been looking through the archives of this list some, but I'm
feel like I'm missing some critical (and probably simple) piece of
information. I'm trying to setup a page in IOWA where the URL
contains some a piece of information needed to render the page.

Basically, I want to take URLs like:

http://localhost:2000/details/FOO/

I obviously need to get more documentation up on the web, as you are the
third person in as many days to ask me this.

The exact implementation will depend on exactly what you are doing. If you
use IRC, hop onto the #IOWA channel on freenode.net, and I'll help you sort
out the precise details without boring the list. I try to monitor the
channel most of the time while I am working. If not, email me at
(e-mail address removed) or (e-mail address removed) or subscribe to the iowa-general
mailing list hosted at rubyforge.

In general, what you want is a change to Main.iwa. Is your app always going
to start at /details?

If so, eliminate the current Main.iwa and Main.html, and mail your
Details.iwa and Details.html into Main.iwa and Main.html.

Then all requests will start with Details, and it can mine the specific
request path (in session.context.request.uri) for whatever details that it
needs.

If you will have other entry points than just /details, then you need to
alter the current Main.iwa. If you haven't, take a look at Main.iwa. It's
extremely simple in implementation. All it is doing is trying to find a
match between the request path and an entry in the mapfile. If it finds
one, that tells it what component to use. It's very easy to customize this
in order to dispatch to the correct components if your needs are more
complex. Let me know if that's what you need to do and I can help enlighten
you on the process (and at the same time that'll help me develop text to
explain the process).


Thanks,

Kirk Haines
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top