• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Custom Fields for ERRest
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom Fields for ERRest


  • Subject: Re: Custom Fields for ERRest
  • From: Luiz Alfredo Carrara Bertusso <email@hidden>
  • Date: Thu, 12 Jan 2017 23:22:18 -0200

Thank you guys, I decided using NSDictionary, if someone finds out an alternative way for this implementation I could do a refactoring in the future.

2017-01-11 17:17 GMT-02:00 Matthew Ness <email@hidden>:



On Thu, Jan 12, 2017, at 06:17 AM, Matthew Ness wrote:
You can also define a new ERKXKey

ERXKey!



in your EO class, create the method it refers to, and use that key in your filter. For example:


Phone.java

public static final ERXKey<String> TYPE_VALUE = new ERXKey<String>("typeValue");

public String typeValue(){
return type().value();
}


PhoneController.java

..
filter.include(Phone.TYPE_VALUE);
filter.exclude(Phone.TYPE);
..




Which may be a little inelegant, but will get you out of that situation. Just be aware that your clients are now looking for the 'typeValue' key, not 'type' and then 'value'. And check for NPE in typeValue().

Regards,

Matt.


--
Matt
http://logicsquad.net



On Thu, Jan 12, 2017, at 02:36 AM, Samuel Pelletier wrote:
Hi,

The default ERRest behaviour is to uses the model as entity format. I do not know a way to uses the built in classes to specify a custom attribute like this.

But you can always use NSArray and NSDictionnary to construct your response like this:

NSMutableArray<NSDictionary<String, Object>> results = new NSMutableArray<NSDictionary<String, Object>>();
for (Phone  phone : phones) {
NSMutableDictionary<String, Object> entry = new NSMutableDictionary<String, Object>();
entry.setObjectForKey(phone.countryCode(), "countryCode");
entry.setObjectForKey(phone.number(), "number");
entry.setObjectForKey(phone.typeTag(), "type");
results.add(entry);
}
return response(results, ERXKeyFilter.filterWithAllRecursive());

Samuel


Le 11 janv. 2017 à 08:55, Luiz Alfredo Carrara Bertusso <email@hidden> a écrit :

Hello, everyone.
I've been using ERRrest for developing, I`d like knowing if it's possible to use custom fields instead of the default ones.
For example, on my model, there's a relationship named type, actually, I have the following response: 
phones": [
    {
      "countryCode": "1",
      "areaCode": "123",
      "number": "1234567",
      "type": {
        "id": [
          1,
          2
        ],
        "typeClass": "Tag",
        "value": "Home"
      }
    }
]

But I'd like to show something like:
phones": [
    {
      "countryCode": "1",
      "areaCode": "123",
      "number": "1234567",
      "type": "Home"
      }
    }
]

Is it possible to create a custom way to show this relationship as above?

Thank you!



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden.com)
Help/Unsubscribe/Update your Subscription:
 
This email sent to email@hidden


--
Matt
http://logicsquad.net


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden.com)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Custom Fields for ERRest (From: Luiz Alfredo Carrara Bertusso <email@hidden>)
 >Re: Custom Fields for ERRest (From: Samuel Pelletier <email@hidden>)
 >Re: Custom Fields for ERRest (From: Matthew Ness <email@hidden>)
 >Re: Custom Fields for ERRest (From: Matthew Ness <email@hidden>)

  • Prev by Date: Re: WOWODC17?? a little OT
  • Next by Date: Re: WOWODC17?? a little OT
  • Previous by thread: Re: Custom Fields for ERRest
  • Next by thread: Storing Session ID in Cookie And Multiple Browser Windows
  • Index(es):
    • Date
    • Thread