On 2/15/08, <b class="gmail_sendername">Stanislav Sinyagin</b> <<a href="mailto:ssinyagin@yahoo.com">ssinyagin@yahoo.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I'm a bit stuck with the use of Actions.<br><br>I want to list the records in a table, and at the end of each row place<br>a link "Delete" which would delete the record.</blockquote><div><br>I think Jesse's suggestion may work, but I have another. <br>
</div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">The code follows. When I click "Delete", the debug log says the corresponding<br>
action is found, but when the Model object's "delete" method is called,<br>it's called in an object that was not loaded from the database, and therefore<br>its ID is unknown, and basically the deletion is not happening:<br>
<br><br><br><br> my $requests = new Toponet::Model::TraceRequestCollection<br> (current_user => Jifty->web->current_user());<br><br> $requests->limit( column => 'startDevice',<br> operator => '=',<br>
value => $deviceID );<br> my $reqs = $requests->items_array_ref();<br><br> if( scalar(@{$reqs}) > 0 )<br> {<br> my $delAction = Jifty->web->new_action<br> (class => 'Toponet::Action::DeleteTraceRequest',<br>
moniker => 'delete_trace_request');<br><br></%perl><br> <P>Existing trace requests:</P><br> <TABLE><br> <TR><br> <TH>Request ID</TH><br> <TH>Submitted</TH><br>
<TH>Status</TH><br> <TH>Target IP</TH><br> <TH>Completed</TH><br> <TH>Results</TH><br> <TH>Action</TH><br> </TR><br><br>
% foreach my $request<br>% (sort {$a->id() <=> $b->id()} @{$reqs}) {<br><br> <TR><br> <TD><% $request->id() %></TD><br> <TD><% scalar(localtime( $request->timeCreated() )) %></TD><br>
<TD><% $request->status() %></TD><br> <TD><% $request->targetValue() %></TD><br> <TD><% $request->status() eq 'complete' ?<br> scalar(localtime( $request->timeComplete() )) : '' %></TD><br>
<TD><% $request->status() eq 'complete' ?<br> '<A HREF="/show_trace_results.html?traceID=' . $request->id() .<br> '">view</A>' : '' |n %></TD><br>
<TD><br> <% Jifty->web->form->start %><br> <% Jifty->web->link<br> (label => 'Delete',<br> as_link => 1,<br> onclick => {<br> submit => $delAction,</blockquote>
<div><br>Replace the line above with:<br><br> submit => { action => $delAction, arguments => { id => $request->id(), }, },<br> <br>and drop the line below starting with "args => ".<br></div><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> args => { id => $request->id() },<br> refresh_self => 1 }) %></TD><br>
<% Jifty->web->form->end %><br> </TR><br><br>% }<br> </TABLE><br>% }<br><br><br><br><br><br>_______________________________________________<br>jifty-devel mailing list<br>
<a href="mailto:jifty-devel@lists.jifty.org">jifty-devel@lists.jifty.org</a><br><a href="http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel">http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel</a><br></blockquote>
</div><br>