You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Kee Hinckley <na...@somewhere.com> on 2002/04/29 23:00:19 UTC

wish - handling of option menus

I wish that

<option value="">None</option>
<option value="_new">New</option>
<option value="[+ (values %Authors)[$row] +]">[+ (keys 
%Authors)[$row] +]</option>

generated one instance of None and New instead of $row instances.   I 
don't think there's any instance when you wouldn't want it to do 
that.  And it would make handling menus much easier.


-- 

Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/
nazgul@somewhere.com

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: wish - handling of option menus

Posted by Axel Beckert - ecos gmbh <be...@ecos.de>.
Hi!

On Mon, Apr 29, 2002 at 05:00:19PM -0400, Kee Hinckley wrote:
> I wish that
> 
> <option value="">None</option>
> <option value="_new">New</option>
> <option value="[+ (values %Authors)[$row] +]">[+ (keys 
> %Authors)[$row] +]</option>
> 
> generated one instance of None and New instead of $row instances.

I guess the usual workaround is known:

[$ if $row == 0 $]
<option value="">None</option>
<option value="_new">New</option>
[$ endif $]
<option value="[+ (values %Authors)[$row] +]">[+ (keys %Authors)[$row] +]</option>

> I don't think there's any instance when you wouldn't want it to do
> that.  And it would make handling menus much easier.

Regarding SELECT, I agree. At least the vast majority of cases works
that way, so it would be a useful default.

            Regards, Axel
-- 
-------------------------------------------------------------
Axel Beckert      ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     beckert@ecos.de         Voice:    +49 6133 926530
WWW:        http://www.ecos.de/     Fax:      +49 6133 925152
-------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: wish - handling of option menus

Posted by Gerald Richter - ecos gmbh <ri...@ecos.de>.
>  In this 
> particular instance it happens to be another one of those cases where 
> a simple while loop doesn't work for me--I'm generating several 
> instances of that menu, so instead I end up doing this:
> 

It works, if you put a simple

[- $set -> Reset -] 

in from of each loop

Gerald



-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: wish - handling of option menus

Posted by Kee Hinckley <na...@somewhere.com>.
At 1:01 PM +0200 5/3/02, Gerald Richter - ecos gmbh wrote:
>Yes, that's true. If this could be the case you need to use a loop, which
>isn't much more to write or wait until I have change Embperl to handle this
>more smart:
>
><select name="person.id:[+ $i +]" onchange="AuthorMenu(this, [+ $i +])">
><option value="">None</option>
><option value="-1">Other...</option>
><option value="">---</option>
>[$ while ($rec = $set -> Next) $]
><option value="[+ $rec->{id} +]">[+ $rec->{sortkey} +]</option>
>[$ endwhile $]
></select>

The work around is clear enough, I just wanted to point out that 
there was an unexpected side effect of Axel's solution.  In this 
particular instance it happens to be another one of those cases where 
a simple while loop doesn't work for me--I'm generating several 
instances of that menu, so instead I end up doing this:

[- $j = 0; -]
[$ while ($set->[$j]{id}) $]
	<option value="[+ $set->[$j]{id} +]">[+ $set->[$j]{sortkey} +]</option>
	[- ++$j -]
[$ endwhile $]

-- 

Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/
nazgul@somewhere.com

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: wish - handling of option menus

Posted by Gerald Richter - ecos gmbh <ri...@ecos.de>.
>
> Just FYI, I discovered there is one place where that technique does not
work.
>
> <select name="person.id:[+ $i +]" onchange="AuthorMenu(this, [+ $i +])">
> [$ if ($row == 0) $]
> <option value="">None</option>
> <option value="-1">Other...</option>
> <option value="">---</option>
> [$ endif $]
> <option value="[+ $set->[$row]{id} +]">[+ $set->[$row]{sortkey
> } +]</option>
> </select>
>
> If there are no items in $set, this will result in an empty menu,
> which is not what you want.

Yes, that's true. If this could be the case you need to use a loop, which
isn't much more to write or wait until I have change Embperl to handle this
more smart:

<select name="person.id:[+ $i +]" onchange="AuthorMenu(this, [+ $i +])">
<option value="">None</option>
<option value="-1">Other...</option>
<option value="">---</option>
[$ while ($rec = $set -> Next) $]
<option value="[+ $rec->{id} +]">[+ $rec->{sortkey} +]</option>
[$ endwhile $]
</select>

Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------





---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: wish - handling of option menus

Posted by Kee Hinckley <na...@somewhere.com>.
At 7:55 AM +0200 5/2/02, Gerald Richter wrote:
>
>Axel already pointed out how to do it right now.

Just FYI, I discovered there is one place where that technique does not work.

<select name="person.id:[+ $i +]" onchange="AuthorMenu(this, [+ $i +])">
	[$ if ($row == 0) $]
		<option value="">None</option>
		<option value="-1">Other...</option>
		<option value="">---</option>
	[$ endif $]
	<option value="[+ $set->[$row]{id} +]">[+ $set->[$row]{sortkey
} +]</option>
</select>

If there are no items in $set, this will result in an empty menu, 
which is not what you want.
-- 

Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/
nazgul@somewhere.com

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: wish - handling of option menus

Posted by Gerald Richter <ri...@ecos.de>.
>
> [$ try/catch etc. $]
>
> I'll have to try that with [* *] and see how it works out.

With 2.0 this should work inside of [* *] blocks inside the same file, it
would cool to get this working even across file boundaries, so you can catch
all the uncaught exceptions in your base.epl (if you use EmbperlObject).
Maybe this could be get to work by using the optReturnError option, but I
didn't have tried it.

Gerald

P.S. Let me/us know if you find anything interesting about exception
handling and Embperl

-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: wish - handling of option menus

Posted by Kee Hinckley <na...@somewhere.com>.
At 5:37 PM +0200 5/2/02, Gerald Richter wrote:
>BTW. In the same way you could use thinks like [* last *], this also works
>inside of [$ while ... $]

That's worth remembering, thanks.

This leads to yet another thought.  It would be interesting to add 
exception handling support to Embperl.  I sometimes use the Error 
module as a wrapper around the perl code in my Embperl files, so that 
I can trap database errors and the like.  But imagine something like 
this:

[$ try $]

html and embperl code

[$ catch Error::Database $]

html dealing with error

[$ otherwise $]

fallback

[$ finally $]

always do this

[$ endtry $]


I'll have to try that with [* *] and see how it works out.
-- 

Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/
nazgul@somewhere.com

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: wish - handling of option menus

Posted by Gerald Richter <ri...@ecos.de>.
>
> Cool.  While I'm in wishlist mode, [$ for (;;) $] would be real
> handy.

ok, should be easy to add. In 2.0 you can always say

[* for (;;) { *]
....
[* } *]

I don't like this syntax very much, because it's really hard to see where
that there is a starting and a end brace inside the [* *] block.

BTW. In the same way you could use thinks like [* last *], this also works
inside of [$ while ... $]

Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: wish - handling of option menus

Posted by Kee Hinckley <na...@somewhere.com>.
At 7:55 AM +0200 5/2/02, Gerald Richter wrote:
>I have tought a little bit about it and came to the conculsion that your way
>to handle it is the more often needed way then the way Embperl currently
>implements it. I think I will realize it in 2.0b8

Cool.  While I'm in wishlist mode, [$ for (;;) $] would be real 
handy.  I find myself often doing things that need to increment by 
two, or need to initialize a variable, and that ends up with stuff 
like:

	[- $i = 0 -]
	[$ while ($i < 10) $]
		...
		[- $i += 2 -]
	[$ endwhile $]

which is the whole reason for statements were invented :-).

-- 

Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/
nazgul@somewhere.com

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: wish - handling of option menus

Posted by Gerald Richter <ri...@ecos.de>.

> I wish that
>
> <option value="">None</option>
> <option value="_new">New</option>
> <option value="[+ (values %Authors)[$row] +]">[+ (keys
> %Authors)[$row] +]</option>
>
> generated one instance of None and New instead of $row instances.   I
> don't think there's any instance when you wouldn't want it to do
> that.  And it would make handling menus much easier.
>

Axel already pointed out how to do it right now.

I have tought a little bit about it and came to the conculsion that your way
to handle it is the more often needed way then the way Embperl currently
implements it. I think I will realize it in 2.0b8

Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: wish - handling of option menus

Posted by Ed Grimm <ed...@asgard.rsc.raytheon.com>.
Agreed.  I never use the EmbPerl menu stuff, because all of my menus
have something which, for whatever reason, can't be in the array.  On a
similar note, I rarely use the tables stuff for a similar reason, but
there are occasions where one wants it to work like it does there.  I
think what I'd prefer for tables is some tag or something to specify a
distinction between the stuff that should be repeated and the stuff that
shouldn't.  However, for options, I can't imagine ever wanting the
current functionality.

Incidentally, mighty bold of you, listing your authors randomly (or is
that one of those tied hash thingies that does maintain order?)  :>

Ed

On Mon, 29 Apr 2002, Kee Hinckley wrote:

> I wish that
>
> <option value="">None</option>
> <option value="_new">New</option>
> <option value="[+ (values %Authors)[$row] +]">[+ (keys
> %Authors)[$row] +]</option>
>
> generated one instance of None and New instead of $row instances.   I
> don't think there's any instance when you wouldn't want it to do
> that.  And it would make handling menus much easier.


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org