Use this code.. this is more wonder compliant:

package com.tos.widgets;

import com.webobjects.appserver.WOContext;
import com.webobjects.appserver.WODisplayGroup;
import com.webobjects.eocontrol.EOEnterpriseObject;
import com.webobjects.foundation.NSArray;
import com.webobjects.foundation.NSMutableDictionary;
import er.directtoweb.components.ERDCustomQueryComponent;

public class TOSD2WQueryBooleanComponent extends ERDCustomQueryComponent
{

    public TOSD2WQueryBooleanComponent(WOContext context)
    {
        super(context);
    }

    public NSArray list()
    {
        return list;
    }

    public Object value()
    {
        propertyKey =(String) valueForBinding("propertyKey");
        displayGroup = (WODisplayGroup)valueForBinding("displayGroup");         

        if(displayGroup != null && displayGroup.queryMatch() != null)
            return displayGroup.queryMatch().objectForKey(propertyKey);
        else
            return null;
    }

    public void setValue(String newValue)
        throws Exception
    {
        propertyKey =(String) valueForBinding("propertyKey");           
        displayGroup = (WODisplayGroup)valueForBinding("displayGroup");

        if(newValue == "don't care")
        {
            displayGroup.queryMatch().takeValueForKey(null, propertyKey);
            displayGroup.queryOperator().takeValueForKey(null, propertyKey);
        } else
        {
            displayGroup.queryMatch().takeValueForKey(newValue, propertyKey);
            displayGroup.queryOperator().takeValueForKey("=", propertyKey);
        }
    }

    public EOEnterpriseObject object;
    public String propertyKey;
    public Object item;
    public WODisplayGroup displayGroup;
    private static NSArray list = new NSArray(new String[] {
        "true", "false"
    });

}




On Feb 17, 2012, at 10:02 AM, Theodore Petrosky wrote:

> James,
> 
> I tried to implement this, so I created my own framework, created the 
> component and added it to my project.
> 
> I used the new component in my rules and it shows the popup on the query 
> page. However, if I select 'true' from the popup I get a 
> NullPointerException. 
> 
> Is there something more that I need to bind in? I named my component 
> "TPSD2WQueryBooleanComponent" and I have only one rule:
> 
>    100 : (pageConfiguration = 'QueryAdRelease' and propertyKey = 'isClosed') 
> => componentName = TPSD2WQueryBooleanComponent 
> [com.webobjects.directtoweb.Assignment],
> 
> What else do I need?
> 
> Ted
> ------------------------------
>> 
>> Message: 7
>> Date: Sun, 12 Feb 2012 08:09:00 -0600
>> From: James Cicenia <[email protected]>
>> To: WebObjects-Dev Mailing List List <[email protected]>
>> Subject: Re: ERD2WCustomQueryBoolean uiStyle
>> Message-ID: <[email protected]>
>> Content-Type: text/plain; charset="utf-8"
>> 
>> Good question. A long time ago I couldn't find one, so I
>> created my own and never looked again.
>> 
>> HTH 
>> James
>> 
>> 
>> binding:
>> 
>> PopUpBoolean: WOPopUpButton {
>>     list = list;
>>     selection = value;
>>     noSelectionString = "-- Select --";
>>     item = item;
>> }
>> 
>> 
>> code:
>> 
>> 
>> 
>> public class TOSD2WQueryBooleanComponent extends
>> ERDCustomQueryComponent
>> {
>> 
>>     public TOSD2WQueryBooleanComponent(WOContext
>> context)
>>     {
>>         super(context);
>>     }
>> 
>>     public NSArray list()
>>     {
>>         return list;
>>     }
>> 
>>     public Object value()
>>     {
>>         if(displayGroup != null
>> && displayGroup.queryMatch() != null)
>>             return
>> displayGroup.queryMatch().objectForKey(propertyKey);
>>         else
>>             return null;
>>     }
>> 
>>     public void setValue(String newValue)
>>         throws Exception
>>     {
>>         if(newValue == "don't care")
>>         {
>>            
>> displayGroup.queryMatch().takeValueForKey(null,
>> propertyKey);
>>            
>> displayGroup.queryOperator().takeValueForKey(null,
>> propertyKey);
>>         } else
>>         {
>>            
>> displayGroup.queryMatch().takeValueForKey(newValue,
>> propertyKey);
>>            
>> displayGroup.queryOperator().takeValueForKey("=",
>> propertyKey);
>>         }
>>     }
>> 
>>     public EOEnterpriseObject object;
>>     public String propertyKey;
>>     public Object item;
>>     public WODisplayGroup displayGroup;
>>     private static NSArray list = new NSArray(new
>> String[] {
>>         "true", "false"
>>     });
>> 
>> }
>> 
>> 
>> On Feb 11, 2012, at 11:40 PM, Theodore Petrosky wrote:
>> 
>>> Finally I got the query page rules working. It seems
>> that I misspelled a propertyKey name.
>>> So, I can not figure out how to control the UI style
>> of:
>>> ERD2WCustomQueryBoolean
>>> 
>>> The default is radio buttons but I would love to see a
>> popup.
>>> 
>>> Ted
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be
>> ignored.
>>> Webobjects-dev mailing list      ([email protected])
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/webobjects-dev/james%40jimijon.com
>>> 
> 

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to