java-ee

Java: Enum case insensitive Jersey Query Param Binding

谁都会走 提交于 2019-12-21 09:43:08
问题 I tried to override/implement all the attribute in JSR311 but the Jersey binding seems case sensitive : Be a primitive type Have a constructor that accepts a single String argument Have a static method named valueOf or fromString that accepts a single String argument (see, for example, Integer.valueOf(String)) Be List, Set or SortedSet, where T satisfies 2 or 3 above. The resulting collection is read-only. How can I make Jersey binding for enum case insensitive? EDIT: Here's the code: The

How to use wkhtmltopdf in Java web application?

久未见 提交于 2019-12-21 09:02:11
问题 I am newbie in wkhtmltopdf . I am wondering how to use wkhtmltopdf with my Dynamic Web Project in Eclipse? How to integrate wkhtmltopdf with my Java dynamic web application? Is there any tutorials available for beginners of wkhtmltopdf ? (Basically, I would like to use wkhtmltopdf in my web application so that when user click a save button , the current page will be saved to PDF file). 回答1: First, a technical note: Because you want to use wkhtmltopdf in a web project, if and when you deploy

“@inject”-ed attribute remains null

社会主义新天地 提交于 2019-12-21 07:15:08
问题 I am trying to inject a service into my bean but it is always null . I get the following error: WELD-001000 Error resolving property userBean against base null. Some code snippets: index.xhtml <h:body> Hello from Facelets #{userBean.name} </h:body> userbean.java package beans; import Domain.User; import java.io.Serializable; import javax.enterprise.context.SessionScoped; import javax.inject.Inject; import javax.inject.Named; import service.UserService; @Named @SessionScoped public class

Did I understand @ModelAttribute right?

我与影子孤独终老i 提交于 2019-12-21 06:07:09
问题 I need help with understanding following example with @ModelAttribute from Spring documentation: (method populatePetTypes() ) @Controller @RequestMapping("/owners/{ownerId}/pets/{petId}/edit") @SessionAttributes("pet") public class EditPetForm { // ... @ModelAttribute("types") public Collection<PetType> populatePetTypes() { return this.clinic.getPetTypes(); } @RequestMapping(method = RequestMethod.POST) public String processSubmit( @ModelAttribute("pet") Pet pet, BindingResult result,

How to use Facebooks Graph-API from a Servlet

北慕城南 提交于 2019-12-21 06:01:18
问题 I need to access Facebook from a J2EE-App (serverside). I first had a look at this project: http://code.google.com/p/facebook-java-api/ , but as I need to create Facebook-Events and invite people this does not help. So I guess I need to use the Graph API, but Igot no clue on how to perform those HTTP POST requests needed - especially how to append the nedded attributes. 回答1: You can use the java.net.URLConnection for this: String url = "http://facebook.com/some/api"; String charset = "UTF-8";

setFirstResult and setMaxResult doesn't work well with Order By

99封情书 提交于 2019-12-21 05:54:08
问题 What could cause the CriteriaQuery orderBy method stop working? Here are the implementations: OpenJPAEntityManager kem = OpenJPAPersistence.cast(entityManager()); kem.getFetchPlan().clearFetchGroups(); kem.getFetchPlan().addFetchGroup("order_search"); CriteriaBuilder builder = kem.getCriteriaBuilder(); CriteriaQuery<Order> query = builder.createQuery(Order.class); Root<Order> order = query.from(Order.class); query.select(order); Predicate main_condition = buildWhereClause(builder, query,

How to check port 8080 in Windows Vista command prompt?

落花浮王杯 提交于 2019-12-21 05:52:37
问题 I am very new to programming and setting up Java Servers. Actually its my first time to try it but not successful. I am about to test my first web app in Java but whenever I click the "Start server in debug mode" button in Eclipse I am always having error about my Tomcat server saying that port 8080 is being used. I wanna know how am I gonna check it in the console and close it if possible. Do you know other ways on dealing with this??? I also tried netstat but can't find the port 8080 among

How to check port 8080 in Windows Vista command prompt?

痴心易碎 提交于 2019-12-21 05:51:06
问题 I am very new to programming and setting up Java Servers. Actually its my first time to try it but not successful. I am about to test my first web app in Java but whenever I click the "Start server in debug mode" button in Eclipse I am always having error about my Tomcat server saying that port 8080 is being used. I wanna know how am I gonna check it in the console and close it if possible. Do you know other ways on dealing with this??? I also tried netstat but can't find the port 8080 among

How can I port a legacy Java/J2EE website to a modern scripting language (PHP,Python/Django, etc)?

两盒软妹~` 提交于 2019-12-21 05:18:08
问题 I want to move a legacy Java web application (J2EE) to a scripting language - any scripting language - in order to improve programming efficiency. What is the easiest way to do this? Are there any automated tools that can convert the bulk of the business logic? 回答1: Here's what you have to do. First, be sure you can walk before you run. Build something simple, possibly tangentially related to your main project. DO NOT build a piece of the final project and hope it will "evolve" into the final

Lookup returns new instance of Stateful session bean

一曲冷凌霜 提交于 2019-12-21 05:11:46
问题 I am using Java EE 5 , EJB 3.0 , Jboss AS 4.3.2 . I have simplest Stateful bean @Local public interface IStateBean { } @Stateful public class StateBean implements IStateBean { private static int number = 0; @PostConstruct void init() { number++; System.out.println("@PostConstruct: " + number); } @PreDestroy void destroy() { number--; System.out.println("@PreDestroy: " + number); } } I do lookup in servlet for this bean public class MyServlet extends HttpServlet { @Override public void doGet