javabeans

Why doesn't ArrayList have getSize() instead of size()?

亡梦爱人 提交于 2019-12-23 10:56:52
问题 I'm making heavy use of ArrayList in some JSP pages. I would like to access an ArrayList like so: ${myArrayList.size} But since objects must to conform to the JavaBean standard, where myArrayList.getMyPropertyName() is ${myArrayList.myPropertyName} in JSP/JSTL, the myArrayList.size() function is not accessible. Is there another class I should be using? Update: It's a bit difficult to accept that a feature such as getting the size of your ArrayList in JSP is left out just for cleaner one

Immediate=true VS immediate=false in JSF Component

折月煮酒 提交于 2019-12-23 07:52:44
问题 I was reading Core JavaServer Faces and I was working on Event Handling. It says that if immediate=true for a component(lets say for a button), when we click that button, the process validation, and invoke application faces of the JSF life cycle will be done early. What does it mean? Can any body explain to me what the immediate=true will affect in each phases? I am confused. Thank you. 回答1: The following link most clearly demonstrates the JSF Lifecycle Phases, How to Debug them, and how

Immediate=true VS immediate=false in JSF Component

梦想的初衷 提交于 2019-12-23 07:52:30
问题 I was reading Core JavaServer Faces and I was working on Event Handling. It says that if immediate=true for a component(lets say for a button), when we click that button, the process validation, and invoke application faces of the JSF life cycle will be done early. What does it mean? Can any body explain to me what the immediate=true will affect in each phases? I am confused. Thank you. 回答1: The following link most clearly demonstrates the JSF Lifecycle Phases, How to Debug them, and how

what is the work-around to “non-static variable cannot be referenced from a static context”? [closed]

纵然是瞬间 提交于 2019-12-23 07:06:30
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . There's a particular idiom to putting a method, or perhaps anonymous inner class, somehow, into the main method of a driver class: package net.bounceme.dur.misc; import net.bounceme.dur.misc.Foo; public class

Unable to create managed bean UserBean - JSF

让人想犯罪 __ 提交于 2019-12-23 05:23:39
问题 I'm trying to create a simple login page that accesses a DB so that when username and password are validated, the id, firstName, lastName are set within the class as well for access. I get this error though: javax.servlet.ServletException: Unable to create managed bean UserBean. The following problems were found: - Property firstName for managed bean UserBean does not exist. Check that appropriate getter and/or setter methods exist. - Property id for managed bean UserBean does not exist.

Embed raw bytes as a PDF in JSP

丶灬走出姿态 提交于 2019-12-23 04:35:18
问题 I have a bean with the raw bytes of a PDF that is generated at the user's request. I want to display this PDF to the user without really persisting the PDF file on my server. In my jsp I have tried tags like <object data="#{bean.pdfBytes}" type="application/pdf" ></object> <object type="application/pdf" width="600" height="400"> <h:outputFormat value="#{bean.pdfBytes}" escape="false"/> </object> but this fails terribly. Any help would be appreciated. Thanks in advance. 回答1: I want to display

jersey 2 multipart pojo is always null

送分小仙女□ 提交于 2019-12-23 03:56:07
问题 I'm trying to write a rest service to upload a file along with some other file information, using Jersey + Jackson. Using multipart, the file is uploaded correctly, and simple fields are OK as well, but the POJO that's supposed to contain additional data, is always null. Simplified example POJO: public class Test { public String name; public Test() {} public String getName() { return name; } public void setName(String name) { this.name = name; } } Application: @ApplicationPath("myapp") public

How to “logic:iterate” just one object?

徘徊边缘 提交于 2019-12-23 03:53:26
问题 So, I have this code: logic:iterate name="nameForm" property="name" id="nameId" indexId="index" bean:write name="nameId" property="field1"/ bean:write name="nameId" property="field2"/ This works great because I'm receiving a "table of objects" so I can do the iterate without issues. Now, on another page I need to do the same but the issue is I am not receiving a "table of objects" but an object itself. I tried it nonetheless and - as expected - got the error: Cannot create iterator for this

Java: Merge 2 “beans” to produce a new one

与世无争的帅哥 提交于 2019-12-23 03:24:10
问题 I need to take all the fields and collections from Bean1 and Bean2, sometimes apply some business logic, and produce Bean3 (all beans are hibernate/domain objects of the same type with a reasonably complex graph). Any thoughts on how to do this? Done something similar in the past? My ideas: Dozer (http://dozer.sourceforge.net/) BeanUtils (http://commons.apache.org/beanutils/) Handrolled solution A.N.Other cool solution? Any recommendations? 回答1: Dozer is a nice bean mapping tool. However, it

JSF & ui:repeat - issue with adding an object to cart

我怕爱的太早我们不能终老 提交于 2019-12-23 01:06:15
问题 Once again I need some help with my pizza-search-programm I have written with Java Server Faces. The program: A user can search for pizzas by entering a form. A filtered search is possible as the user can decide whether he searches for a pizza name, a pizza id or other specified criteria. The program will generate a SQL query which returns pizza objects and stores it into a list of objects. A JSF page displays the list of pizza objects by iterating them through a ui:repeat tag. Pizza name,