in reply to Mason design issue.
So let me try understand what is going on.
1) You have a set of web forms that each do some action
2) Foreach action you wrote a mason component to handle the submission.
3) Each form should be capable to do this action in stand alone.
4) Each form can be combined into a general page with other forms so you can create the admin view. But each form has variables that are the same.
5) After executing the action, the portion of the admin that submitted the data should display something in the general page.
You're questions:
1) How to combine the different forms in a container so that each form calls the appropriate component without the names of the attributes clashing?
2) Return to the general page the result of your action?
The solution to problem 1:
Create a small java script that you include in every page (using a dhandler for example):
function perform_action(link,form_handled) { var form=document.forms[form_handled]; form.action=link; form.submit(); }
In each web form, name each form in the form tag:
<form method="post" name="<% $form_name %>"> ... </form>
For each button on your page, define now the form and the path to your component for each web form:
<button type=button onclick="perform_action('<% component_path %>' +,'<% $form_name>%')">submit</button>
By naming your forms in the web page, you can use a small javascript to select the correct one by name and submit the data. The name clash disappears because each attribute is unique in each form.
This is also usable when only one form is needed on a page. So you don't have to include ugly 'if-else' structures in your mason code for your web forms to handle the different cases. The javascript is quite light and i didn't had any compatibility problems with it.
Because each web form has an unique name and his proper link to his component, only the specified component is called. Be aware, the mason component doesn't know yet from where it is called. He can distinguish the call from the single web form from the call of the general page.
Still to do, problem2: display the result in the admin console instead. Or make the component known from where it is called.
Solution to this depends on the general architecture of your application. If you have a MVC architecture, the controller can take care of that part. If not, I recommend hidden fields. It isn't that ugly and will solve your problem quickly.
I hope this shed some light, otherwise, feel free to specify more in detail what your problem is.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Mason design issue.
by EvanCarroll (Chaplain) on Oct 12, 2005 at 07:15 UTC |