How to leverage existing LT GUI with a local LT server?

I have a web application written using a couple of javascript APIs. I have installed language tool running as a local server.
What I need is a javascript GUI that will show errors and corrections in my web application’s textareas/div tags. Since the server is returning in xml format, the javascript api should parse and render the errors with suggested corrections.

I tried to follow the instructions given in Integration On Websites - LanguageTool Wiki. I replaced languagetool_rpc_url and the form action attribute to use my local language tool server. It didn’t work and it looks like I am missing a critical piece.

Before I dissect the tinymce javascript to understand its logic, I would like to know if anyone has done such a thing before and if any hint is available to share.

Thanks in advance!
Yoto

By default, Javascript can only access data on the same domain and, I think, on the same port as the page it has been loaded from. So I think your Javascript on localhost won’t be able to access localhost:8081 where LT is running. That’s why there’s a proxy.php as a default in the languagetool_rpc_url. You will need this proxy script to access your LT server.

I ended up creating a new rest service and used the RuleAsXmlSerializer class to return in the same xml format. I used this rest services’s endpoint in the languagetool_rpc_url attribute and it is able to make the communication now. The only issue I am having now is with css. I dont see the grammar corrections display on the UI now. I am going to take a deep dive into it.

@POST
	@Produces(MediaType.TEXT_XML)
	public String correct(@QueryParam("text") String text) {

		JLanguageTool langTool = null;
		List<RuleMatch> matches = null;
		try {
			langTool = new JLanguageTool(new AmericanEnglish());
			langTool.activateDefaultPatternRules();

			matches = langTool.check(text);

		} catch (IOException e) {
			e.printStackTrace();
		}
		
		RuleAsXmlSerializer atd = new RuleAsXmlSerializer();
		return atd.ruleMatchesToXml(matches, text, 45, null);
	}