Re: SubmitButton Component
Re: SubmitButton Component
- Subject: Re: SubmitButton Component
- From: Benjamin Miller <email@hidden>
- Date: Wed, 12 Mar 2003 10:13:48 +0000
I started with the examples in the WOComponentElements framework and
didn't have any problems using the multiple submit button example when
using a WOGenericElement or WOGenericContainer. I wanted the trailing
slash on the element and I wasn't sure if using a container to produce
<input type="submit" name="1.5"></input> is allowed in xhtml. It
renders correctly in browsers and works with WO.
The problem I had was my incorrect implementation of invokeAction(). I
also bound an action to the component without an ivar or method so I
guess it was key value coding calling the method multiple times that
also confused me.
Once my invokeAction() was fixed I went back and used and WOXMLNode
without problems.
<WEBOBJECT NAME=XMLNode1></WEBOBJECT>
XMLNode1: WOXMLNode {
elementName = "input";
name = context.elementID;
type = "submit";
value = ^value;
}
public class ImageSubmit extends WOComponent {
public ImageSubmit(WOContext context) {
super(context);
}
public boolean synchronizesVariablesWithBindings() {
return false;
}
public WOActionResults invokeAction(WORequest request, WOContext
context) {
return (WOComponent) valueForBinding("action");
}
}
Thanks for your help, Benjamin
On Wednesday, March 12, 2003, at 01:57 am, David Neumann wrote:
> I think you are going to have to use a custom WOForm that is
> implemented as a Component to get this to work. See WXForm in the
> WOComponentElements framework source in the JavaWebObjects Examples.
>
> BTW: this I think this might be a better implementation of your button:
>
>
>
> // .html file:
> <WEBOBJECT NAME=SubmitButton></WEBOBJECT>
>
>
>
> // .wod file:
> SubmitButton: WOGenericElement {
> elementName = "input";
> type = "submit";
> value = ^value;
> invokeAction = ^action;
> name = context.elementID;
> }
>
>
>
> // .java
> public class SubmitButton extends WOComponent {
>
> public SubmitButton( WOContext aContext ) {
> super( aContext );
> }
>
> public boolean synchronizesVariablesWithBindings() {
> return false;
> }
> }
>
>
>
> Take a look at the other WOComponents in WOComponentElements, it might
> be the ideal starting point to creating your own library of custom
> elements (e.g. for different presentation dialects like WAP, XHTML,
> XSL:FO, etc...
>
> d
>
>
>
>
> On Tuesday, March 11, 2003, at 04:26 PM, Benjamin Miller wrote:
>
>> I'm trying to implement a XHTML submit button to be used inside a
>> WOForm with multiple submit buttons. So far I think I have tried most
>> methods unsuccessfully. I currently have a WOComponent with a single
>> binding to an action in the parent component.
>>
>> public class ImageSubmit extends WOComponent {
>>
>> public String action;
>>
>> public ImageSubmit(WOContext context) {
>> super(context);
>> }
>>
>> public void appendToResponse(WOResponse response, WOContext
>> context) {
>> response.appendContentString("<input type=\"submit\"
>> name=\"");
>> response.appendContentString(context.elementID());
>> response.appendContentString("\" />");
>> }
>>
>> public WOComponent invokeAction() {
>> NSLog.out.appendln("invokeAction in component");
>> return
>> (WOComponent)performParentAction((String)valueForBinding("action"));
>> }
>>
>> }
>>
>> invokeAction() doesn't appear to be called, although the method in the
>> parent component executes four times in one response loop. Any ideas
>> where I am going wrong? The WOForm does not have an action binding and
>> multiple submit is true. Whilst experimenting earlier I found that I
>> appeared to have problems with the elementID generated. What does
>> WebObjects do if it can't find the component with the elementID that
>> submitted the form?
>>
>> Is this the best way to handle generation of small chunks of HTML like
>> this or are WODynamicElements in some way 'better' ? I did read
>> somewhere in the Apple docs that there was little difference between
>> components and dynamic elements since version 4 or so.
>>
>> Obviously working through all the above, I haven't found a nice
>> framework full of XHTML elements and components so I guess one doesn't
>> exist.
>>
>> Benjamin Miller
>>
>>
>> --
>> Happy 21st birthday to Watershed....
>> We need your thoughts, memories and experiences of Watershed past,
>> present and future to help celebrate Watersheds 21st birthday. FFI
>> go to
>> http://www.watershed.co.uk/development . Send in your contributions by
>> email
>> to: email@hidden
>>
>> +44 (0)117 927 6444 t / +44 (0)117 921 3958 f /
>> http://www.watershed.co.uk
>> Watershed Media Centre, 1 Canon's Road, Harbourside, Bristol, BS1 5TX
>> _______________________________________________
>> webobjects-dev mailing list | email@hidden
>> Help/Unsubscribe/Archives:
>> http://www.lists.apple.com/mailman/listinfo/webobjects-dev
>> Do not post admin requests to the list. They will be ignored.
>>
>
>
--
Happy 21st birthday to Watershed....
We need your thoughts, memories and experiences of Watershed past,
present and future to help celebrate Watersheds 21st birthday. FFI
go to
http://www.watershed.co.uk/development . Send in your contributions by
email
to: email@hidden
+44 (0)117 927 6444 t / +44 (0)117 921 3958 f /
http://www.watershed.co.uk
Watershed Media Centre, 1 Canon's Road, Harbourside, Bristol, BS1 5TX
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.