aspose file tools*
The moose likes JForum and the fly likes Create new topic via an application ... whats the best way to do it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JForum
Bookmark "Create new topic via an application ... whats the best way to do it" Watch "Create new topic via an application ... whats the best way to do it" New topic
Author

Create new topic via an application ... whats the best way to do it

Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Hello,

I want to use JForums to discuss items of an application that I am making. So when an item in the application is created, a topic in Jforums should be created as well.

First I tried it by manually creating the tables and disabling the topic cache in JForum. That did not work since Toplink essentials can't manage the structure JForum uses (yes, sounds weird, but somehow it fails on the connection of topic to the posts as soon as I add the OneToOne topic_last_post_id apart from the OneToMany that is needed for more obvious reasons)

I then thought of making net.jforum.view.forum.PostAction an EJB3 bean, adding a method to create a topic and a Remote interface to call it. But then I noticed that I'd have to turn the web-application into an ejb3-module, at least I think that this must be the reason why the jndi lookup failed and I also did not see anything in my JNDI tree on the server.

So now I'd like to ask what you would consider the easiest way to create (and later also automatically delete) a topic in jforums through an external application. Any ideas?

best regards,
David
[originally posted on jforum.net by Hellek]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Probably the easiest way to do this with the current version is to use something like the Apache Commons HTTPClient to post your topic. I believe there are plans for an API to allow stuff like this in the works... don't know if it's part of 2.1.8 which is in alpha( or is it beta?) right now.


[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Ok, I should not have asked for a simple solution, HTTPClient IS simple, yes, but probably the ugliest possible solution.

I now managed to do it with a webservice. Only took me about two hours to figure out how to set one up.

When I am done with everything, I will post the links to the sources here. Its part of my bachelor thesis.
[originally posted on jforum.net by Hellek]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Well, technically, since jForum URLs pretty much conform to the REST principles, using HTTP and JForum can also be consider using it as a SoA webservice.

So, it's ugly is just in how you market it... you could say it was state of the art REST-ful programming. Especially, if you use a templates that just returns XML.
[originally posted on jforum.net by monroe]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
you convinced me. And it works perfectly btw, thanks for the advice.
The webservice-solution was just too unstable since my adaptions to get rid of the need of request/context stuff were rather quick'n'dirty.
[originally posted on jforum.net by Hellek]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Hi Hellek, i would to know how you make your solution with web services. I want do similar solution to create a new topic and list topics in my application.

Thanks.
[originally posted on jforum.net by feusebio]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
I'd be interested to know the solution too.

monroe wrote: I believe there are plans for an API to allow stuff like this in the works... don't know if it's part of 2.1.8 which is in alpha( or is it beta?) right now.



is there anything new in the version 2.1.8 concerning that matter?

Thank you
[originally posted on jforum.net by August]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Hi all,

well, after fooling around a little bit and looking the forum code I found a way to create new topics from another application. Not sure if this is a right and clean way. If somebody will find something better - all suggestions will be thankfully accepted Here it is:



It's just a dummy servlet that creates a new topic in the forum, created partly by "copy & paste" from other programs. I call it from another servlet that actually contains just a small form with a text field for the subject and a submit button.
[originally posted on jforum.net by August]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
Another thing which I could not yet find is - how can I get the URL of a new topic, so that it works like this:

1. A click on the button or some other action
2. A new topic is created
3. The user sees the URL of the new topic

Does anyone know this?

Thank you!
[originally posted on jforum.net by August]
Migrated From Jforum.net
Ranch Hand

Joined: Apr 22, 2012
Posts: 17424
If someone wants to know:

Paste this between the line 79 and the catch block in the example above, and it does the trick:

[originally posted on jforum.net by August]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Create new topic via an application ... whats the best way to do it