You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "G.L. Grobe" <ga...@grobe.net> on 2003/02/14 22:44:42 UTC

view method not calling

Anyone have ideas or comment on what I might be doing wrong here.  I 
have a velocity view that creates many checkboxes pending the number of 
result sets returned from a dbase query. The getter method in my 
webwork action is called when the page is loaded but the setter (which 
I expect to be called for each checkbox on submittal so that I can 
collect which checkboxes are checked) isn't.

--- my.vm

    #foreach ( $set in $toolsList )
          <input type="checkbox" name="$toolItem($set.name)">$set.name
    #end

--- webwork action

// gets called when view page is loaded
	public String[] getToolItem() { return items; }

// I thought should be called when the form is submitted, but doesn't
  	public void setToolItem(String[] tools) {
		this.items = tools;
	}

Any help much appreciated.


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: view method not calling

Posted by Dave Newton <da...@solaraccess.com>.
On Mon, 2003-02-17 at 23:18, Gary Grobe wrote:
> >>   #foreach ( $set in $toolsList )
> >>         <input type="checkbox" name="$toolItem($set.name)">$set.name
> >>   #end
> >
> > Do you mean ${set.toolItem} or something like that?
> 
> No, I mean just like I have it above. It works like that, but I can 
> tell from all the reactions I'm using it wrong. I don't understand what 
> the reference name should be I think.

I guess I'm confused then, because at one point you said $toolItem was a
method. If it's a method, then there has to be a object containing that
method. If it's not a method, then it's an object, and the above isn't
syntactically correct (I think).

Ah well :)

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: view method not calling

Posted by Nathan Bubna <na...@esha.com>.
Gary said:
...
> >> But as I have below, $toolItem() is the method to be called, and when
> >> the view loads, the getToolItem is called, but on submittal,
> >> setToolItem doesn't get called. So if you thought getName was the
> >> method as you have above, what was $toolItem as you have above?
> >
> > You're saying that $toolItem() is the method to be called, but with
> > what
> > object would it be called? You have it all by itself:
>
> I have a webwork action that returns this velocity view and I have
> get/setToolItem() methods in it. So if I'm using it wrong, it seems to
> work, at least for loading the page view, but not submitting it.

it works for loading (i.e. rendering the html)?  if so, then velocity has
done it's job, afaict.  if the VTL (velocity template language) that you are
showing us is rendering properly to HTML (i.e.  no spurious $references in
the output), then sounds like a question you should ask on webwork's list.
remember, velocity is merely a template language, not a framework.  it
doesn't really know anything about "submitting" things.

> >>   #foreach ( $set in $toolsList )
> >>         <input type="checkbox" name="$toolItem($set.name)">$set.name
> >>   #end
> >
> > Do you mean ${set.toolItem} or something like that?
>
> No, I mean just like I have it above. It works like that, but I can
> tell from all the reactions I'm using it wrong. I don't understand what
> the reference name should be I think.

the basics of velocity are as follows:

put an instance of com.foo.Bar in the context w/a key like "bar"
render the object in the context as
$bar
and the output will be equivalent to myBar.toString()
if you wish to render the result of one of myBar's other methods, do things
like:
$bar.whatever()  (calls myBar.whatever() and renders result)
$bar.blah   (typically calls myBar.getBlah() and renders result)
#set( $bar.blah = 'ugh' )  (equivalent to myBar.setBlah("ugh"))

if these don't work or fit your situation, then i strongly suggest asking th
e webwork list where people will be more likely to understand what you are
trying to do.

Nathan Bubna
nathan@esha.com


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: view method not calling

Posted by Gary Grobe <ga...@grobe.net>.
>
>> But as I have below, $toolItem() is the method to be called, and when
>> the view loads, the getToolItem is called, but on submittal,
>> setToolItem doesn't get called. So if you thought getName was the
>> method as you have above, what was $toolItem as you have above?
>
> You're saying that $toolItem() is the method to be called, but with 
> what
> object would it be called? You have it all by itself:

I have a webwork action that returns this velocity view and I have 
get/setToolItem() methods in it. So if I'm using it wrong, it seems to 
work, at least for loading the page view, but not submitting it.

>>   #foreach ( $set in $toolsList )
>>         <input type="checkbox" name="$toolItem($set.name)">$set.name
>>   #end
>
> Do you mean ${set.toolItem} or something like that?

No, I mean just like I have it above. It works like that, but I can 
tell from all the reactions I'm using it wrong. I don't understand what 
the reference name should be I think.


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: view method not calling

Posted by Dave Newton <da...@solaraccess.com>.
On Sun, 2003-02-16 at 16:55, G.L. Grobe wrote:
> But as I have below, $toolItem() is the method to be called, and when 
> the view loads, the getToolItem is called, but on submittal, 
> setToolItem doesn't get called. So if you thought getName was the 
> method as you have above, what was $toolItem as you have above?

You're saying that $toolItem() is the method to be called, but with what
object would it be called? You have it all by itself:

>   #foreach ( $set in $toolsList )
>         <input type="checkbox" name="$toolItem($set.name)">$set.name
>   #end

Do you mean ${set.toolItem} or something like that?

Dave



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: view method not calling

Posted by "G.L. Grobe" <ga...@grobe.net>.
I guess I'm not understanding something about references then ...

>> Anyone have ideas or comment on what I might be doing wrong here.  I 
>> have a velocity view that creates many checkboxes pending the number 
>> of result sets returned from a dbase query. The getter method in my 
>> webwork action is called when the page is loaded but the setter 
>> (which I expect to be called for each checkbox on submittal so that I 
>> can collect which checkboxes are checked) isn't.
>>
>> --- my.vm
>>
>>    #foreach ( $set in $toolsList )
>>          <input type="checkbox" name="$toolItem($set.name)">$set.name
>>    #end
>
> I'm not quite sure what you are asking, but above,
>
>    $toolItem($set.name)
>
> is missing the method to be called.  I would expect something like
>
>
>     $toolItem.getName($set.name)
>
> or similar.

But as I have below, $toolItem() is the method to be called, and when 
the view loads, the getToolItem is called, but on submittal, 
setToolItem doesn't get called. So if you thought getName was the 
method as you have above, what was $toolItem as you have above?

>>
>> --- webwork action
>>
>> // gets called when view page is loaded
>> 	public String[] getToolItem() { return items; }
>>
>> // I thought should be called when the form is submitted, but doesn't
>>  	public void setToolItem(String[] tools) {
>> 		this.items = tools;
>> 	}


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: view method not calling

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On Friday, February 14, 2003, at 04:44 PM, G.L. Grobe wrote:

> Anyone have ideas or comment on what I might be doing wrong here.  I 
> have a velocity view that creates many checkboxes pending the number 
> of result sets returned from a dbase query. The getter method in my 
> webwork action is called when the page is loaded but the setter (which 
> I expect to be called for each checkbox on submittal so that I can 
> collect which checkboxes are checked) isn't.
>
> --- my.vm
>
>    #foreach ( $set in $toolsList )
>          <input type="checkbox" name="$toolItem($set.name)">$set.name
>    #end

I'm not quite sure what you are asking, but above,

    $toolItem($set.name)

is missing the method to be called.  I would expect something like


     $toolItem.getName($set.name)

or similar.

geir

>
> --- webwork action
>
> // gets called when view page is loaded
> 	public String[] getToolItem() { return items; }
>
> // I thought should be called when the form is submitted, but doesn't
>  	public void setToolItem(String[] tools) {
> 		this.items = tools;
> 	}
>
> Any help much appreciated.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
-- 
Geir Magnusson Jr                                   203-956-2604(w)
Adeptra, Inc.                                       203-247-1713(m)
geirm@adeptra.com


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org