|
Perhaps you can create a “DirectAction” instead of trying to do it with a component action. Make methods in DirectAction.java. This might be your first cut.
Another option is to create REST routes (ERRest) - which are a specialized direct actions. This might be your second cut.
> On Apr 15, 2021, at 2:52 PM, Michele Varano <webobjects-dev@wocommunity.org> wrote:
>
> Hello all
>
> I have a JavaScript based calendar " FullCalendar V5 / https://fullcalendar.io/docs/v3/events-function "
> which I build in Java via script.
> So far no problem, but now I want to display my events dynamically/ fetch them from
> the DB depending on the custom filter
> One option I saw in the doc is to fetch the events via function,
> which is called whenever the calendar needs new dates/events,
>
> Example from doc:
>
> THE OLD VERSION
>
> $('#calendar').fullCalendar({
> events: function(start, end, timezone, callback) {
> $.ajax({
> url: 'myxmlfeed.php',
> dataType: 'xml',
> data: {
> // our hypothetical feed requires UNIX timestamps
> start: start.unix(),
> end: end.unix()
> },
> success: function(doc) {
> var events = [];
> $(doc).find('event').each(function() {
> events.push({
> title: $(this).attr('title'),
> start: $(this).attr('start') // will be parsed
> });
> });
> callback(events);
> }
> });
> }
> });
>
> THE NEW VERSION
>
> import { req } from 'superagent'; // ajax library
>
> var calendar = new Calendar(calendarEl, {
>
> events: function(info, successCallback, failureCallback) {
> req.get('myxmlfeed.php')
> .type('xml')
> .query({
> start: info.start.valueOf(),
> end: info.end.valueOf()
> })
> .end(function(err, res) {
>
> if (err) {
> failureCallback(err);
> } else {
>
> successCallback(
> Array.prototype.slice.call( // convert to array
> res.getElementsByTagName('event')
> ).map(function(eventEl) {
> return {
> title: eventEl.getAttribute('title'),
> start: eventEl.getAttribute('start')
> }
> })
> )
> }
> })
> }
>
> });
>
> My question now is, how do I build the URL so that I can call
> an action method, perhaps with parameters, in my component?
> Or maybe you have a better idea how to do this:)
>
> Many Thanks
>
> Michele
> #############################################################
> This message is sent to you because you are subscribed to
> the mailing list <webobjects-dev@wocommunity.org>.
> To unsubscribe, E-mail to: <webobjects-dev-off@wocommunity.org>
> To switch to the DIGEST mode, E-mail to <webobjects-dev-digest@wocommunity.org>
> To switch to the INDEX mode, E-mail to <webobjects-dev-index@wocommunity.org>
> Send administrative queries to <webobjects-dev-request@wocommunity.org>
>
|
|