[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] Navigation Templates and Run Mode


From: B10m <suppressed>
>If you don't like to use the PATH_INFO to base the runmode on, and find 'rm' too cryptic,

You're right, I should use path_info. I don't think path_info was available when I began doing it the way I do (or, it didn't dawn on me until I read about it a few months ago). What I do seemed less cryptic (to me) than using "?rm=4"

One reason I have a nasty if/else block in my setup method is that a form may have multiple submits. They all go to the same "?subarea=xxx" because that's in the form's action attribute. But, when the setup method gets ahold of it, it has to determine which submit button was pressed. It does this by determining which of the available submit names has a value. It is the submit name that correlates to the run mode that should be used within the object. 

In other words, run_mode isn't directly correlated to URL. Whether I use rm=4. Or, subarea=account. Or "/account", I would still need a if/else block in the setup method to interrogate the submit buttons to determine which has a value and was thus the button pressed.

So, right now I might have something like the following to determine if the run mode (subarea parameter) is present and (if it is) which submit was pressed. In this example, the form has 3 submits to change the password, resend an email verification, or change the account values (everything except password):

==============================
if (defined($self->{q}->param('subarea'))) {

  if ($self->{q}->param('subarea') eq 'account') {
    if    (defined($self->{q}->param('change_psw'))) {
      $self->start_mode('21');
    }
    elsif (defined($self->{q}->param('change_acc'))) {
      $self->start_mode('22');
    }
    elsif (defined($self->{q}->param('send_verify'))) {
      $self->start_mode('23');
    }
    else {
      $self->start_mode('20'); # default view for the subarea (when no submit was pressed)
    }
  } # end profile area = account
elsif () {
  [ maybe a lot of these for each subarea of a person's profile (account, personal information, etc.) ]
}
else {
  $self->start_mode('1'); # default view when no subarea is provided.
}
==============================

I do it this way so I have less run modes in the HTML. The subarea parameter get to the high-level areas of functionality. But, the name of the submit button pressed gets to the actual internal run mode (which maps to the actual method).

>There's also $self->start_mode('mode1'); This would set the 'initial entry' view.

As you see, I use that. I just don't set it until I've tested whether any known "subarea=value" pairs exist. Instead of initializing it, it becomes the "otherwise" value.

Thanks,
Mark



---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.