IOWA: hyperlinks and dynamic components

D

Daniel Cremer

Hi,

I've been doing a tour of web application frameworks and right now I'm
playing with IOWA which seems very solid indeed.
One type of component I need to be able to write is one that would
contain a dynamic list of hyperlinks to select choices. Such as for a
menu generated by a CMS where users could create the navigation bar
themselves. I would approach this by having one method called by all the
hyperlinks with a parameter indicating which option was selected.

I found a way to do it but I'm sure there must be a better solution. I
quickly hacked a component that consisted of a hyperlink where the
template including it could define the method to be invoked and a
parameter to include. The menu component could then dynamically edit
it's own template to include these custom hyperlinks as necessary.
Is there some support in Iowa I haven't grasped that would make this
easier ?

thanks,
-Daniel


The custom component I mention is below. It would be added to the Menu
component like this:
<SelectLink oid="select1" action="select_link" param="choice1"
text="link1" />
<SelectLink oid="select2" action="select_link" param="choice2"
text="link2"/>
....


-----SelectLink.html------
<a oid="link_selected">@text</a>
----------------------------

-----SelectLink.iwa-------
class SelectLink < Iowa::Component
attr_reader :text

def awake()
@action = @attributes['action']
@param = @attributes['param']
@text = @attributes['text']
end

def link_selected()
@parent.send(@action, @param)
end

end
--------------------------------------
 

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,880
Messages
2,569,944
Members
46,247
Latest member
DominikSta

Latest Threads

Top