WebService component

There was avery useful component called WebService available in Enyo 1.0. I don't see it in the Enyo 2.0 API doc. Is this or a similar component available in 2.0? If not now, will it be?

Comments

  • In Enyo 2.0, this isn't a component anymore. Instead, it's just an object you can create called enyo.Ajax. I'm not sure why better docs for this aren't showing up online, but you can read the inline docs at https://github.com/enyojs/enyo/blob/master/source/ajax/Ajax.js
  • hmm. Would the 1.0 webservice work if moved over, possibly adjusted some? Its really quite nice, and all my existing code uses it :)
  • It won't work immediately since we've removed enyo.xhrGet and enyo.xhrPost, but I don't think it would take much porting. Remember, Enyo 2.0 is a big refactoring and rewrite from 1.0... we're not trying to be API compatible or even have exactly the same set of widgets.
  • Thank you. I'll check out Ajax.js.
  • I will miss WebService, though.
  • Hate to say it, but there were a number of things I liked about Enyo 1.0 (SlidingPanes, WebService, not having to figure out if I need to add something to "classes" or not). Sad to hear that they are not going to make it over to Enyo 2.0.
  • SlidingPane and WebService will exist soon in Enyo 2.0, albeit in slightly different forms.

    Although, please don't be afraid of enyo.Ajax. It does everything WebService did, but is much more flexible. If you are having problems understanding how to use it, please ask a question on this forum!
    not having to figure out if I need to add something to "classes" or not
    Can you be more specific? From my perspective, the use of 'classes' has only improved in Enyo 2.0.
  • Yes, I guess I just need to get more comfortable with it. With WebService, I liked being able to send in "onSuccess" & "onFailure" events/functions - seemed more logical than doing the "request.response(this, successFunction)". I think for the newbie, the earlier way of doing things is more quickly understood.

    With regards to classes: with old Enyo, there were just kinds (e.g., Divider, Spacer, VirtualList). With new Enyo, sometimes I have to use a "kind" (e.g., {kind: "onyx.Toolbar"}); in other cases, classes (e.g., {classes: "divider"}); sometimes both (e.g. {kind:"List", classes:"list"}); sometimes, neither (e.g., {fit:true} for Spacer). I guess I could just create kinds for all of these to replicate the old way but seems like it should just be part of the framework.

    I understand the new use of classes is more flexible...but it still makes it more complicated :)
  • Ok, thanks for letting us know. We'll think about how to simplify these things.

    A couple of quick notes.

    There is no 'list' class you need to use, like this {kind:"List", classes:"list"}. If you saw that in an example, it's just the example writer wanting to style his List, like you could style anything.

    Second, maybe you know this already, but {fit: true} can be on any Control inside a Fittable.
  • Hi

    I have used the web service component to access one web service which on local host.

    But it's not work..........

    This is my code............
    enyo.kind({
    name: "HelloWebservice",
    kind: enyo.Components,
    components:
    [
    { name: "getFeed",
    kind: "WebService",
    url: "http://localhost:2908/Service1.asmx?op=HelloWorld",
    onSuccess: "gotFeed",
    onFailure: "gotFeedFailure"
    },

    { kind: "Button",
    content: "Get Feed",
    onclick: "btnClick"
    },
    { name: "output", classes: "sample-output" }
    ],

    btnClick: function (inSender, inEvent)
    {
    this.$.getFeed.call();
    },

    gotFeed: function (inSender, inResponse, inRequest)
    {
    this.$.output.setContent("Login successful");
    },

    onFailure: function (inSender, inResponse, inRequest)
    {
    this.$.output.setContent("Login failed");
    }

    });

    new HelloWebservice().write();
    On button click event , I have to call that web service but its not work........

    So, please any one know the solution of this code/problem......correct it

    PH
  • It should be:
    	
    { name: "webService",
    kind:"enyo.WebService",
    url: url,
    onResponse: "fetchSuccess",
    onError: "fetchFailure",
    });
    Note onReponse & onError instead of onSuccess and onFailure.
  • (modified last two comments from @psarin and @PrashantHadole to use proper pre and code tags around code segments)

    Note: the handlers for onResponse and onError have the standard event handler form, with only two parameters: inSender and inEvent. The event structure has two properties, ajax and data, which correspond with the internal enyo.Ajax object and the response data.
  • Sorry (and thanks!) Ben.. :(
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Twitter