Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change color of event. #180

Closed
evalls opened this issue Jul 8, 2015 · 8 comments
Closed

Change color of event. #180

evalls opened this issue Jul 8, 2015 · 8 comments
Labels

Comments

@evalls
Copy link

evalls commented Jul 8, 2015

Hi sebfz1 please i have 2 questions,
1- how can i Change the Color of a CalendarEvent?
2- when i use a downloadlink i can generate a file for the user like This:

DownloadLink link = new DownloadLink(wicketID, new AbstractReadOnlyModel() {
private static final long serialVersionUID = 1L;

        @Override
        public File getObject() {
            File tempFile;
            try {
                tempFile = File.createTempFile("test", ".csv");
                InputStream data = new ByteArrayInputStream("some calendarEvent".getBytes());
                Files.writeTo(tempFile, data);

            } catch (IOException e) {
                throw new RuntimeException(e);
            }

            return tempFile;
        }
    }
    ).setCacheDuration(Duration.NONE).setDeleteAfterDownload(true);
    return link;
}

how can i do it in a onsubmit methode of a button: i am trying to export my CalenderEvents?

I hope you will help me..........

@evalls
Copy link
Author

evalls commented Jul 8, 2015

ok thk you for your fast answer. I will try it now and let you know.

@evalls
Copy link
Author

evalls commented Jul 8, 2015

is there some thing to pay attention again when i export CalendarEvent. I use what you show me and i'm getting this error:

Wicket.Ajax.Call.failure: Error while parsing response: Not Found

@sebfz1
Copy link
Owner

sebfz1 commented Jul 8, 2015

Hi,

Additionally if you would like to change the color in a lazy way (when these are loaded by the model) you could make YourCalendarModel implements ICalendarVisitor.

https://github.com/sebfz1/wicket-jquery-ui/blob/master/wicket-jquery-ui-samples/src/main/java/com/googlecode/wicket/jquery/ui/samples/data/DemoCalendarModel.java#L29

Best regards,
Sebastien

@evalls
Copy link
Author

evalls commented Jul 8, 2015

My onSubmit() look like this:

@OverRide
public void onSubmit(AjaxRequestTarget target)
{

          final File file = new File("myfile"); // that is just a test
    if (file == null)
    {
        throw new IllegalStateException(getClass().getName() +
            " failed to retrieve a File object from model");
    }


    String fileName = fileNameModel != null ? fileNameModel.getObject() : null;
    if (Strings.isEmpty(fileName))
    {
        fileName = file.getName();
    }

    IResourceStream resourceStream = new FileResourceStream(
        new org.apache.wicket.util.file.File(file));
                    Duration cacheDuration = null;
    getRequestCycle().scheduleRequestHandlerAfterCurrent(
        new ResourceStreamRequestHandler(resourceStream)
        {
            public void respond(IRequestCycle requestCycle)
            {
                super.respond(requestCycle);
                                boolean deleteAfter = false;

                if (deleteAfter)
                {
                    Files.remove(file);
                }
            }
        }.setFileName(fileName)
            .setContentDisposition(ContentDisposition.ATTACHMENT)
            .setCacheDuration(cacheDuration));


                    }

@sebfz1
Copy link
Owner

sebfz1 commented Jul 8, 2015

The error message is not clear enough to me to identify the issue.
I don't exactly how your code looks like, but to export datatable rows for instance, I have the following:
https://github.com/sebfz1/wicket-jquery-ui/blob/master/wicket-kendo-ui/src/main/java/com/googlecode/wicket/kendo/ui/datatable/export/CSVDataExporter.java (itself based on wicket's CSVDataExporter).

The usage is as simple as: `@ Override public void onSubmit() { CSVDataExporter.export(myTable, "table.csv"); }

Maybe can you get inspiration from this, replacing the DataTable/IDataProvider by Calendar/CalendarModel...

@evalls
Copy link
Author

evalls commented Jul 9, 2015

Thk you martin and sebfz1,
i made it. I can change the Color of my Events.......

@sebfz1 sebfz1 closed this as completed Jul 14, 2015
@sebfz1 sebfz1 added the question label Aug 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants