开发者

Connect a standalone application to web browser-Java

开发者 https://www.devze.com 2023-02-07 02:34 出处:网络
I\'m developing a stand alone timetable scheduling system using netbeans IDE and i would like to link the output (ie a created schedule/timetable) to the web browser so that it can be viewed from ther

I'm developing a stand alone timetable scheduling system using netbeans IDE and i would like to link the output (ie a created schedule/timetable) to the web browser so that it can be viewed from there once a user logs in. Ho开发者_运维问答w should i go about it?


Write a service that both desktop and browser UIs can access the same way. Both can display the same data.


You could encapsulate the logic in a service, say ScheduleService (or TimetableService). Suppose you have the following interface definining your ScheduleService:

public interface ScheduleService {

    public List<Appointment> getAppointments(Date when);
    public void setAppointment(Date when, Appointment appointment);

}

Then you provide your implementation under ScheduleServiceImpl:

public class ScheduleServiceImpl implements ScheduleService {

    public List<Appointment> getAppointments(Date when) {
        // TODO: get list of appointments
    }

    public void setAppointment(Date when, Appointment appointment) {
        // TODO: create appointment
    }
}

In your GUI code, you would directly use your ScheduleServiceImpl, while the WebService would use a proxy method. Obviously, these proxy methods should also implement the ScheduleService interface, but in their implementation they would delegate all calls to the real implementation.

public class ScheduleServiceWebServiceImpl implements ScheduleService {
    ScheduleService realImplementation = new ScheduleServiceImpl(); 

    public List<Appointment> getAppointments(Date when) {
        return realImplementation.getAppointments(when);
    }

    public void setAppointment(Date when, Appointment appointment) {
        realImplementation(when, appointment);
    }
} 

}

For the WebService part, of course, you might want to transform the output (via a JSP, or XSLT) to generate HTML or any other output format.


My friend "Dhiral Pandya" develop this browser for his college project may be, this will help you

My Button is open source java web browser.

Develop for school and college projects and learning purpose. Download source code extract .zip file and copy “mybutton” folder from “parser\mybutton” to C:\

Import project “omtMyButton” in eclipse. Require Java 6.

Download .exe and source code : https://sourceforge.net/projects/omtmybutton/files/

0

精彩评论

暂无评论...
验证码 换一张
取 消