webtek-devel Mailing List for WebTek (Page 4)
Status: Alpha
Brought to you by:
prozessor13
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(3) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(1) |
Feb
|
Mar
|
Apr
(1) |
May
(3) |
Jun
(1) |
Jul
|
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(1) |
2008 |
Jan
|
Feb
|
Mar
(1) |
Apr
(10) |
May
(32) |
Jun
(65) |
Jul
(31) |
Aug
(9) |
Sep
(15) |
Oct
(9) |
Nov
(24) |
Dec
(12) |
2009 |
Jan
(32) |
Feb
(4) |
Mar
(13) |
Apr
(28) |
May
(66) |
Jun
(76) |
Jul
(45) |
Aug
(24) |
Sep
(22) |
Oct
(30) |
Nov
(6) |
Dec
(3) |
2010 |
Jan
|
Feb
|
Mar
(39) |
Apr
(46) |
May
(61) |
Jun
(48) |
Jul
(38) |
Aug
(45) |
Sep
(20) |
Oct
|
Nov
|
Dec
|
2011 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: max d. <pro...@gm...> - 2008-06-16 07:53:31
|
hmmm.. this is no bug, because you used the macro in a wrong way. the format of a macro is defined like: <% handler.handler.macro_name param1="abc" param2=" ... <% ... %> ..." | filter1 | filter2 param="..." %> if you omit the handler (i.e. you want to call a macro in the current page) you can write: <% macro_name param1="abc" param2=" ... <% ... %> ..." | filter1 | filter2 param="..." %> for better understanding you can think the above macro-call is the same as: <% actual_page.macro_name ... %> (but the handler actual_page dont exists, because it's already the default) so to your example: i think you want to put the current iterator (which is a handler obj) as a param to a macro, like: sub a_macro { my ($self, %params) = @_; return $params{'iterator_obj'}->some_macro(); } but this is not possible because, when you write: <% a_macro iterator_obj="<% xyz %>" %> xyz is called as a macro function for the current page (and this is exactly the error-msg from your example) so, there are two solutions for this problem. 1) our solution with the self macro have done the trick (because it returns the handler obj) 2) handler xyz is already defined for the current page (from the foreach macro), so you can write in the macro-code: sub a_macro { my ($self, %params) = @_; return $self->handler($params{'handler_name'})->some_macro(); } and in the template <% foreach iterator="xyz" do~q{ <% a_macro handler_name="xyz" %> } %> hmmm... i think the second solution is not as nice as the first, because you have to split the logic: half in the template (the handler- name) and half in macro-code (handler-obj for the handler-name).. and this solution also only works in the same page, where the foreach is called. so a <% foreach iterator="xyz" do~q{ <% parent.a_macro handler_name="xyz" %> } %> wouldn't work! so i think we should implement a general macro which returns the obj of the current handler (like your self macro). what would you think is the right name for such an macro? is sub self :Macro { ... } a good name? i think its ok, so we should implement this in WebTek/Handler.pm lg. max. On 15.06.2008, at 13:49, Adrian Smith wrote: > I just searched for ages for this bug! > > <% foreach list="...." iterator="xyz" do~q{ > <% a_macro param="<% xyz %>" %> > } %> > > This doesn't work, producing the error: > > macro_error : MyApp::Page::MyPage=HASH(0x227f904) has no macro 'xyz' > > If I implement the following method in class Xyz: > > sub self :Macro { > my $self = shift; > return $self; > } > > and then put the following in the template: > > <% foreach list="...." iterator="xyz" do~q{ > <% a_macro param="<% xyz.self %>" %> > } %> > > Then it works fine |
From: max d. <pro...@gm...> - 2008-06-16 06:45:08
|
you have to use the format_number filter. <% input name="costs_national" handler="profile" | format_number %> On 15.06.2008, at 12:13, Adrian Smith wrote: > Thanks for your commits and face-to-face discussions concerning this > issue. > > Unfortunately I cannot get it to work. Maybe I am doing something > wrong? > > (1) in MyApp/config/numbers.config I have: > > 'de' => { 'thousands_sep' => '.', 'decimal_point' => ',' }, > > (2) in the main CGI program I have: > > request->language("de"); > > The strings from "de.po" are displayed correctly (there is no > "en.po") so I am confident that the language is set correctly in the > CGI. > > (3) in the template, I have: > > <% input name="costs_national" handler="profile" %> > > (4) the field in the MySQL database is a DECIMAL(10,2) > > However, I only get the English ("." decimal separator) used both > (a) in the display of values in the form field, and (b) in the > parsing of the value. > > I am sure this worked before? Or maybe I am mistaken? > > Thanks in advance for your help > > > > 2008/6/11 Adrian Smith <adr...@gm...>: > Thinking about this, one would definitely need some kind of filter > that worked 2-way i.e. can convert firstly from an internal > representation to an external representation (like the current > filter), and also the other way around (for input fields). > > Similar to the NumberFormatter or DateFormatter concept in Cocoa and > WebObjects: > > http://developer.apple.com/documentation/DeveloperTools/Reference/WO541Reference/com/webobjects/foundation/NSNumberFormatter.html > > 2008/6/11 Adrian Smith <adr...@gm...>: > > I see that there is the filter "format_number" which takes into > account e.g. "." or "," for the decimal and thousand separators. > That's really great! > > Is there anything equivalent for data input? > > Specifically I have a database field of the type "decimal(10,2)" and > I have a text field which must display the data, and accept inputed > data, using the German decimal separator. > > |
From: max d. <pro...@gm...> - 2008-06-16 06:41:15
|
> > <% profie.costs_national | format_number format="%.2f" %> you have guessed exactly the syntax ;) .... this is already implemented... |
From: Adrian S. <adr...@gm...> - 2008-06-15 15:09:46
|
Strangely this works in a different page (i.e. input fields are populated with "," and accept ",") but the code is the same as the page where it doesn't work! Maybe you can take a look when we next meet .... 2008/6/15 Adrian Smith <adr...@gm...>: > Thanks for your commits and face-to-face discussions concerning this issue. > > Unfortunately I cannot get it to work. Maybe I am doing something wrong? > > (1) in MyApp/config/numbers.config I have: > > 'de' => { 'thousands_sep' => '.', 'decimal_point' => ',' }, > > (2) in the main CGI program I have: > > request->language("de"); > > The strings from "de.po" are displayed correctly (there is no "en.po") so I > am confident that the language is set correctly in the CGI. > > (3) in the template, I have: > > <% input name="costs_national" handler="profile" %> > > (4) the field in the MySQL database is a DECIMAL(10,2) > > However, I only get the English ("." decimal separator) used both (a) in > the display of values in the form field, and (b) in the parsing of the > value. > > I am sure this worked before? Or maybe I am mistaken? > > Thanks in advance for your help > > > > > 2008/6/11 Adrian Smith <adr...@gm...>: > >> Thinking about this, one would definitely need some kind of filter that >> worked 2-way i.e. can convert firstly from an internal representation to an >> external representation (like the current filter), and also the other way >> around (for input fields). >> >> Similar to the NumberFormatter or DateFormatter concept in Cocoa and >> WebObjects: >> >> >> http://developer.apple.com/documentation/DeveloperTools/Reference/WO541Reference/com/webobjects/foundation/NSNumberFormatter.html >> >> 2008/6/11 Adrian Smith <adr...@gm...>: >> >>> I see that there is the filter "format_number" which takes into account >>> e.g. "." or "," for the decimal and thousand separators. That's really >>> great! >>> >>> Is there anything equivalent for data input? >>> >>> Specifically I have a database field of the type "decimal(10,2)" and I >>> have a text field which must display the data, and accept inputed data, >>> using the German decimal separator. >>> >> >> > |
From: Adrian S. <adr...@gm...> - 2008-06-15 11:56:08
|
I just searched for ages for this bug! <% foreach list="...." iterator="xyz" do~q{ <% a_macro param="<% xyz %>" %> } %> This doesn't work, producing the error: macro_error : MyApp::Page::MyPage=HASH(0x227f904) has no macro 'xyz' If I implement the following method in class Xyz: sub self :Macro { my $self = shift; return $self; } and then put the following in the template: <% foreach list="...." iterator="xyz" do~q{ <% a_macro param="<% xyz.self %>" %> } %> Then it works fine |
From: Adrian S. <adr...@gm...> - 2008-06-15 10:13:38
|
Thanks for your commits and face-to-face discussions concerning this issue. Unfortunately I cannot get it to work. Maybe I am doing something wrong? (1) in MyApp/config/numbers.config I have: 'de' => { 'thousands_sep' => '.', 'decimal_point' => ',' }, (2) in the main CGI program I have: request->language("de"); The strings from "de.po" are displayed correctly (there is no "en.po") so I am confident that the language is set correctly in the CGI. (3) in the template, I have: <% input name="costs_national" handler="profile" %> (4) the field in the MySQL database is a DECIMAL(10,2) However, I only get the English ("." decimal separator) used both (a) in the display of values in the form field, and (b) in the parsing of the value. I am sure this worked before? Or maybe I am mistaken? Thanks in advance for your help 2008/6/11 Adrian Smith <adr...@gm...>: > Thinking about this, one would definitely need some kind of filter that > worked 2-way i.e. can convert firstly from an internal representation to an > external representation (like the current filter), and also the other way > around (for input fields). > > Similar to the NumberFormatter or DateFormatter concept in Cocoa and > WebObjects: > > > http://developer.apple.com/documentation/DeveloperTools/Reference/WO541Reference/com/webobjects/foundation/NSNumberFormatter.html > > 2008/6/11 Adrian Smith <adr...@gm...>: > >> I see that there is the filter "format_number" which takes into account >> e.g. "." or "," for the decimal and thousand separators. That's really >> great! >> >> Is there anything equivalent for data input? >> >> Specifically I have a database field of the type "decimal(10,2)" and I >> have a text field which must display the data, and accept inputed data, >> using the German decimal separator. >> > > |
From: Adrian S. <adr...@gm...> - 2008-06-15 10:07:32
|
In addition to "," vs "." decimal separators, is there any way to influence the formatting of a number, that appears as the default value in a field, for example with a Filter? In my template, I have: <% input class="FormField" name="costs_national" handler="profile" %> and in the database a DECIMAL(10,2). When the value "12.00" is in the database, then (understandaly) the value "12" is displayed in the input field, as Perl chops away the needless 0s in the decimal part. However as I am dealing with money, I would like to display those decimal places. I undertand with a <% profie.costs_national | format_number format="%.2f" %> this would be possible. Is anything like this for an input field? |
From: Adrian S. <adr...@gm...> - 2008-06-15 10:03:00
|
Unfortunately there is an (obscure) bug in this code: sub save :Action { my $self = shift; > > if (request->is_post) { > my @ids = request->params->profile_cost->id; > my @amounts = request->params->profile_cost->amount; > ... > > foreach (0 ... $#ids) { > my $profile_cost = > app::Model::ProfileCost->find_one(id=>$ids[$_]); > $profile_cost->amount($amounts[$_]); > ... > $profile_cost->save; > ... > } > } > The problem is that if there are 0 entries in the foreach, then there are no fields with the "profile_cost___" prefix, and therefore in "params" the hash "profile_cost" is undefined. Then the run-time error: error in MyPage=HASH(0x2237750) during action 'index': Can't call method "id" on an undefined value at ..... results. I have solved the problem by putting an if (..) around the block of code which handles those input fields, and now it works. But I wonder if there is a more elegant solution, rather than the if (..) ? |
From: Adrian S. <adr...@gm...> - 2008-06-11 15:04:52
|
Thinking about this, one would definitely need some kind of filter that worked 2-way i.e. can convert firstly from an internal representation to an external representation (like the current filter), and also the other way around (for input fields). Similar to the NumberFormatter or DateFormatter concept in Cocoa and WebObjects: http://developer.apple.com/documentation/DeveloperTools/Reference/WO541Reference/com/webobjects/foundation/NSNumberFormatter.html 2008/6/11 Adrian Smith <adr...@gm...>: > I see that there is the filter "format_number" which takes into account > e.g. "." or "," for the decimal and thousand separators. That's really > great! > > Is there anything equivalent for data input? > > Specifically I have a database field of the type "decimal(10,2)" and I have > a text field which must display the data, and accept inputed data, using the > German decimal separator. > |
From: Adrian S. <adr...@gm...> - 2008-06-11 14:54:29
|
Currently if the user enters more data in an html field than is allowed in a database column, an error is displayed to the user. This is certainly a very useful feature! It would also be possible to set the maximum length of the html form, so that the browser would not allow further characters to be entered. If the field was VARCHAR(20), then one could create a form field like: <input name="xxx" ..... maxlength="20"> I implemented a similar feature for www.easyname.eu and it was useful! On MySQL, VARCHAR(n) specifies that there are n characters (not bytes) available in the field, according to this document (although I have not tried it to confirm): http://dev.mysql.com/doc/refman/5.0/en/char.html In Oracle, however, it would not be possible, as VARCHAR2(n) specifies that there are n bytes available in the field. But for MySQL it would be a useful feature! I am not sure how such a feature would be implemented, though. |
From: Adrian S. <adr...@gm...> - 2008-06-11 14:45:41
|
I see that there is the filter "format_number" which takes into account e.g. "." or "," for the decimal and thousand separators. That's really great! Is there anything equivalent for data input? Specifically I have a database field of the type "decimal(10,2)" and I have a text field which must display the data, and accept inputed data, using the German decimal separator. |
From: max d. <pro...@gm...> - 2008-06-11 14:14:45
|
On Jun 11, 2008, at 3:24 PM, Adrian Smith wrote: > I have the following situation: > There is a Profile, with various information (first name, last name, > etc.) > Each Profile has multiple ProfileCosts. This is a simple table, with > a PK, a FK to the Profile, a "cost name" and an "amount" > The front-end should contain lots of fields.O > One HTML field for each field in the Profile, and one HTML field for > each "Profile Cost" row. > The rows already exist by the time the form is reached. > When the user clicks "save", the Profile should be updated, and the > ProfileCost rows should be updated. > When the form is displayed all fields should be populated with their > current values from the database. > I am thinking of the following approach: > Profile fields displayed with <% input name="field_name" > handler="profile" %> as usual > A new macro like <% profile_cost_fields %> > This macro renders a template with the text and the HTML field, once > for each ProfileCost > The HTML field names are something like "profile_cost_nnnn" where > "nnn" is the PK of the ProfileCost object > On the action method, I search for all request->params with that > sort of name, load the ProfileCost with this id, and update it > Is there a better approach, or shall I do it as above? > > It would be nice just to "iterate over the ProfileCost" objects, for > example: > > <% foreach list="profile.all_profile_costs" iterator="profile_cost" > %> > <% profile_cost.cost_name %> > <% input value="profile_cost.amount" %> > <br/> > <% /foreach %> > > But I can't see how that could be possible? But is there a nicer way > than what I've proposed? wait one hour, and you can do this: in your template: <% foreach list="<% profile.all_profile_costs %>" iterator="profile_cost" do=q{ <% profile_cost.cost_name %> <% input type="hidden" name="id" handler="profile_cost" %> <% input name="amount" handler="profile_cost" %> ... <br /> } %> an in your page: sub save :Action { my $self = shift; if (request->is_post) { my @ids = request->params->profile_cost->id; my @amounts = request->params->profile_cost->amount; ... foreach (0 ... $#ids) { my $profile_cost = app::Model::ProfileCost->find_one(id=> $ids[$_]); $profile_cost->amount($amounts[$_]); ... $profile_cost->save; ... } } maybe this solution is dangerous, but it should work, alternatively you could use your proposal, but choose the name of the form fields like: <% input name="profile_cost_<% profile_cost.id %>___amount" default_value="<% profile_cost.amount %>" %> use the ___ syntax, to automatically group your params --> so you can access the form-data via: request->params->profile_cost_123; #=> hash with all form params for one profile_cost |
From: Adrian S. <adr...@gm...> - 2008-06-11 13:24:47
|
I have the following situation: - There is a *Profile*, with various information (first name, last name, etc.) - Each Profile has multiple *ProfileCost*s. This is a simple table, with a PK, a FK to the Profile, a "cost name" and an "amount" The front-end should contain lots of fields.O - One HTML field for each field in the Profile, and one HTML field for each "Profile Cost" row. - The rows already exist by the time the form is reached. - When the user clicks "save", the Profile should be updated, and the ProfileCost rows should be updated. - When the form is displayed all fields should be populated with their current values from the database. I am thinking of the following approach: - Profile fields displayed with <% input name="field_name" handler="profile" %> as usual - A new macro like <% profile_cost_fields %> - This macro renders a template with the text and the HTML field, once for each ProfileCost - The HTML field names are something like "profile_cost_nnnn" where "nnn" is the PK of the ProfileCost object - On the action method, I search for all request->params with that sort of name, load the ProfileCost with this id, and update it Is there a better approach, or shall I do it as above? It would be nice just to "iterate over the ProfileCost" objects, for example: <% foreach list="profile.all_profile_costs" iterator="profile_cost" %> <% profile_cost.cost_name %> <% input value="profile_cost.amount" %> <br/> <% /foreach %> But I can't see how that could be possible? But is there a nicer way than what I've proposed? |
From: Adrian S. <adr...@gm...> - 2008-06-11 12:45:30
|
OK fine I'll do the __PACKAGE__ solution - thanks ! But it seemed to me logical that the non-equal relationship between the class-names and the table-names was already taken care of with the TABLE_NAME function? 2008/6/11 max demmelbauer <pro...@gm...>: > webtek tries to generate a classname for a column which ends with _id. and > in your case the generation of the classname does not match your real > classname. you can do 2 things: > > * extend WebTek in Model.pm line 135 and below (sub has_a { ... }) to check > also for a classname in CamelCase > * or define a has_a relation in your Profile Class > > TariffCalc/Model/Profile.pm > > use base qw( WebTek::Model ); > > __PACKAGE__->has_a('sales_person_id', 'TariffCalc::Model::SalesPerson); > > ... > > On Jun 11, 2008, at 2:31 PM, Adrian Smith wrote: > > I should mention that the "profile" table has the a field "sales_person_id" > > 2008/6/11 Adrian Smith <adr...@gm...>: > >> I have: >> >> - A table "profile" with a class TariffCalc::Model::Profile >> - A table "sales_person" with a class TariffCalc::Model::SalesPerson >> - Each "profile" belongs to a "sales_person" >> >> In the SalesPerson class there is a TABLE_NAME function. >> >> All works well. I can create a "profile" which references an existing >> "sales_person". >> >> However on the ProfileView page, I get the error: >> >> general error, details: Can't locate object method "new" via package >> "TariffCalc::Model::Sales_Person" (perhaps you forgot to load >> "TariffCalc::Model::Sales_Person"?) at >> D:/Adrian/customer-checkouts/webtek/lib/WebTek/Model.pm line 555. >> >> What am I doing wrong? >> >> Thanks! >> > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > > http://sourceforge.net/services/buy/index.php_______________________________________________ > Webtek-devel mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webtek-devel > > > |
From: max d. <pro...@gm...> - 2008-06-11 12:41:05
|
webtek tries to generate a classname for a column which ends with _id. and in your case the generation of the classname does not match your real classname. you can do 2 things: * extend WebTek in Model.pm line 135 and below (sub has_a { ... }) to check also for a classname in CamelCase * or define a has_a relation in your Profile Class TariffCalc/Model/Profile.pm use base qw( WebTek::Model ); __PACKAGE__->has_a('sales_person_id', 'TariffCalc::Model::SalesPerson); ... On Jun 11, 2008, at 2:31 PM, Adrian Smith wrote: > I should mention that the "profile" table has the a field > "sales_person_id" > > 2008/6/11 Adrian Smith <adr...@gm...>: > I have: > A table "profile" with a class TariffCalc::Model::Profile > A table "sales_person" with a class TariffCalc::Model::SalesPerson > Each "profile" belongs to a "sales_person" > In the SalesPerson class there is a TABLE_NAME function. > > All works well. I can create a "profile" which references an > existing "sales_person". > > However on the ProfileView page, I get the error: > > general error, details: Can't locate object method "new" via package > "TariffCalc::Model::Sales_Person" (perhaps you forgot to load > "TariffCalc::Model::Sales_Person"?) at D:/Adrian/customer-checkouts/ > webtek/lib/WebTek/Model.pm line 555. > > What am I doing wrong? > > Thanks! > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/index.php_______________________________________________ > Webtek-devel mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webtek-devel |
From: Adrian S. <adr...@gm...> - 2008-06-11 12:31:46
|
I should mention that the "profile" table has the a field "sales_person_id" 2008/6/11 Adrian Smith <adr...@gm...>: > I have: > > - A table "profile" with a class TariffCalc::Model::Profile > - A table "sales_person" with a class TariffCalc::Model::SalesPerson > - Each "profile" belongs to a "sales_person" > > In the SalesPerson class there is a TABLE_NAME function. > > All works well. I can create a "profile" which references an existing > "sales_person". > > However on the ProfileView page, I get the error: > > general error, details: Can't locate object method "new" via package > "TariffCalc::Model::Sales_Person" (perhaps you forgot to load > "TariffCalc::Model::Sales_Person"?) at > D:/Adrian/customer-checkouts/webtek/lib/WebTek/Model.pm line 555. > > What am I doing wrong? > > Thanks! > |
From: Adrian S. <adr...@gm...> - 2008-06-11 12:30:46
|
I have: - A table "profile" with a class TariffCalc::Model::Profile - A table "sales_person" with a class TariffCalc::Model::SalesPerson - Each "profile" belongs to a "sales_person" In the SalesPerson class there is a TABLE_NAME function. All works well. I can create a "profile" which references an existing "sales_person". However on the ProfileView page, I get the error: general error, details: Can't locate object method "new" via package "TariffCalc::Model::Sales_Person" (perhaps you forgot to load "TariffCalc::Model::Sales_Person"?) at D:/Adrian/customer-checkouts/webtek/lib/WebTek/Model.pm line 555. What am I doing wrong? Thanks! |
From: Adrian S. <adr...@gm...> - 2008-06-04 19:20:05
|
How does this work with WebTek? I see there is a config entry for the time-zone, by default set to CEST. Does one have to change that when it becomes winter, and change it back when it becomes summer? |
From: max d. <pro...@gm...> - 2008-06-04 17:33:36
|
On Jun 4, 2008, at 7:11 PM, Adrian Smith wrote: > I have the problem that I want to have a list on a page. The page is > called MarketingMaterialList and there is a MarketingList model, > taking its data from the database. > > It is simply a list of the data, with no actions such as "view" or > "delete". (There is a single link "download", which is a link to a > URL contained within the marketing material.) > > Normaly I would iterate over the list and create > MarketingMaterialView page for each entry in the list. However in > this case there is no MarketingMaterialView page. And I don't think > it's appropriate to create one, just so it can contain a > "list_item.tpl". (This would create confusion for a web designer, or > later developer, who looked at the code, who would for sure assume > that the page existed and was reachable, if the template directory > and Page .pm file existed.) > > So I was wondering if it would be possible to use parameters. In the > <% list %> macro in the page: > sub list :Macro { > my ($self, %params) = @_; > > my $list = $self->paginator('list')->items(); > foreach my $item (@$list) { > print $self->render_template('list_row', { > 'name' => $item->name(), > 'created_on' => $item->created_on(), > 'download_href' => $item->download_href(), > } ); > } > return; > } > And in the "list_row.tpl" I have: > <tr> > <td><% name | truncate limit="30" %></td> > <td><% created_on %></td> > <td><% link display="Download" href="<% download_href %>" %></td> > </tr> <tr> <td><% param.name | truncate limit="30" %></td> <td><% param.created_on %></td> ... </tr> > However the template parser complains: > [Wed Jun 04 19:05:08 2008] [error] [client 127.0.0.1] [2008-06-04 > 190508] [WebTek:error] WebTek::Exception: error in > TariffCalc::Page::SalesPerson::MarketingMaterialList=HASH(0x2ec9660) > during action 'index': WebTek::Exception: error compiling template > D:/Adrian/data/occupation/20080414-onestopconcept-tariff/webtek-apps/ > TariffCalc/templates/SalesPerson/MarketingMaterialList/list_row.tpl, > details macro_error : > TariffCalc::Page::SalesPerson::MarketingMaterialList=HASH(0x2ec9660) > has no macro 'name' > What is the correct approach here? |
From: Adrian S. <adr...@gm...> - 2008-06-04 17:11:11
|
I have the problem that I want to have a list on a page. The page is called MarketingMaterialList and there is a MarketingList model, taking its data from the database. It is simply a list of the data, with no actions such as "view" or "delete". (There is a single link "download", which is a link to a URL contained within the marketing material.) Normaly I would iterate over the list and create MarketingMaterialView page for each entry in the list. However in this case there is no MarketingMaterialView page. And I don't think it's appropriate to create one, just so it can contain a "list_item.tpl". (This would create confusion for a web designer, or later developer, who looked at the code, who would for sure assume that the page existed and was reachable, if the template directory and Page .pm file existed.) So I was wondering if it would be possible to use parameters. In the <% list %> macro in the page: sub list :Macro { my ($self, %params) = @_; my $list = $self->paginator('list')->items(); foreach my $item (@$list) { print $self->render_template('list_row', { 'name' => $item->name(), 'created_on' => $item->created_on(), 'download_href' => $item->download_href(), } ); } return; } And in the "list_row.tpl" I have: <tr> <td><% name | truncate limit="30" %></td> <td><% created_on %></td> <td><% link display="Download" href="<% download_href %>" %></td> </tr> However the template parser complains: [Wed Jun 04 19:05:08 2008] [error] [client 127.0.0.1] [2008-06-04 190508] [WebTek:error] WebTek::Exception: error in TariffCalc::Page::SalesPerson::MarketingMaterialList=HASH(0x2ec9660) during action 'index': WebTek::Exception: error compiling template D:/Adrian/data/occupation/20080414-onestopconcept-tariff/webtek-apps/TariffC alc/templates/SalesPerson/MarketingMaterialList/list_row.tpl, details macro_error : TariffCalc::Page::SalesPerson::MarketingMaterialList=HASH(0x2ec9660) has no macro 'name' What is the correct approach here? |
From: Adrian S. <adr...@gm...> - 2008-06-04 11:03:57
|
I would be tempted to treat the empty string the same as "null" when checking field validity. I think that if one writes "not null" in the database schema, then one also wants to disallow empty strings. But I don't really know if one wants this. Certainly I want this right now. And I think one would generally want this. But I could imagine there being other opinions about this. I mean when do you want, in a database schema a) disallow null b) allow empty string? I can't think of a time. Indeed, Oracle treats the empty string as null (= you get a db error, when you insert "" into a not-null column) - but Oracle gets a lot of criticism for this feature :) _____ From: max demmelbauer [mailto:pro...@gm...] Sent: Wednesday, June 04, 2008 10:01 To: Adrian Smith Cc: web...@li... Subject: Re: [Webtek-devel] Fields being empty and the "empty" error On 03.06.2008, at 21:38, Adrian Smith wrote: In Model.pm: if (!$column->{'nullable'} and !defined($value)) { $errors->{$name} = "empty"; next CHECK; } and in a Page I wrote: $obj->name(request->params->marketing_material->name()); I could have used the general new_default(...) method which takes all params, but as I set all the other values in the model explicitly, it seemed more convenient to show which attributes of the model get set from where. Anyway, the "empty" error does not get fired in this case. Whereas if I replace the code in my Page with the following: $obj->name(request->params->marketing_material->name() || undef); Then it works perfectly. hmm.. this is a genereal problem with GET/POST parameters, because there only exists empty strings, and an empty string ist different than NULL. i also ran into this problem, and my solution is (like you) to define the PROPERTIES field. sorry but i dont know a good solution for this problem. do you? Is it really reasonable to test to see if $value is defined? If it is defined, but empty, although it's technically possible to save it into a "not null" column (in MySQL, but not in Oracle), is that really what the programmer would intend, with the "not null" keyword? I suppose one can always set a PROPERTIES regexp of /./ - this is what I have done and it works great - but I just think that this auto-"not null" feature is nice. But as it is now, it doesn't really work as one would expect. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_____________________ __________________________ Webtek-devel mailing list Web...@li... https://lists.sourceforge.net/lists/listinfo/webtek-devel |
From: max d. <pro...@gm...> - 2008-06-04 08:00:54
|
On 03.06.2008, at 21:38, Adrian Smith wrote: > In Model.pm: > > if (!$column->{'nullable'} and !defined($value)) { > $errors->{$name} = "empty"; > next CHECK; > } > and in a Page I wrote: > > $obj->name(request->params->marketing_material->name()); > I could have used the general new_default(...) method which takes > all params, but as I set all the other values in the model > explicitly, it seemed more convenient to show which attributes of > the model get set from where. > > Anyway, the "empty" error does not get fired in this case. Whereas > if I replace the code in my Page with the following: > > $obj->name(request->params->marketing_material->name() || > undef); > Then it works perfectly. hmm.. this is a genereal problem with GET/POST parameters, because there only exists empty strings, and an empty string ist different than NULL. i also ran into this problem, and my solution is (like you) to define the PROPERTIES field. sorry but i dont know a good solution for this problem. do you? > > Is it really reasonable to test to see if $value is defined? If it > is defined, but empty, although it's technically possible to save it > into a "not null" column (in MySQL, but not in Oracle), is that > really what the programmer would intend, with the "not null" keyword? > > I suppose one can always set a PROPERTIES regexp of /./ - this is > what I have done and it works great - but I just think that this > auto-"not null" feature is nice. But as it is now, it doesn't really > work as one would expect. > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________ > Webtek-devel mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webtek-devel |
From: max d. <pro...@gm...> - 2008-06-03 21:10:26
|
define: sub access_denied :Action { ... } in your page.. On Jun 3, 2008, at 9:38 PM, Adrian Smith wrote: > If the session has expired, the user receives a "not authorized" page > access_denied for action index > Is it possible to customize this page, for example > State the conditions which must be met for the user to access the > page, for example "you must be logged in as a administration > user" (in my case there are two types of user) > Provide a link to the log-in screen > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________ > Webtek-devel mailing list > Web...@li... > https://lists.sourceforge.net/lists/listinfo/webtek-devel |
From: Adrian S. <adr...@gm...> - 2008-06-03 19:39:18
|
If the session has expired, the user receives a "not authorized" page access_denied for action index Is it possible to customize this page, for example * State the conditions which must be met for the user to access the page, for example "you must be logged in as a administration user" (in my case there are two types of user) * Provide a link to the log-in screen |
From: Adrian S. <adr...@gm...> - 2008-06-03 19:39:05
|
In Model.pm: if (!$column->{'nullable'} and !defined($value)) { $errors->{$name} = "empty"; next CHECK; } and in a Page I wrote: $obj->name(request->params->marketing_material->name()); I could have used the general new_default(...) method which takes all params, but as I set all the other values in the model explicitly, it seemed more convenient to show which attributes of the model get set from where. Anyway, the "empty" error does not get fired in this case. Whereas if I replace the code in my Page with the following: $obj->name(request->params->marketing_material->name() || undef); Then it works perfectly. Is it really reasonable to test to see if $value is defined? If it is defined, but empty, although it's technically possible to save it into a "not null" column (in MySQL, but not in Oracle), is that really what the programmer would intend, with the "not null" keyword? I suppose one can always set a PROPERTIES regexp of /./ - this is what I have done and it works great - but I just think that this auto-"not null" feature is nice. But as it is now, it doesn't really work as one would expect. |