I’m a huge believer in consistency, and hence conventions.
However, I’m currently developing a framework in Java where these conventions (specifically the get/set prefix convention) seem to get in the way of readability. For example, some classes will have id and name properties and using o.getId() instead of o.id() seems utterly pointl...
I'm not sure about the difference. I'm using Hibernate and, in some books, they use JavaBean and POJO as an interchangeable term. I want to know if there is a difference, not just in the Hibernate context, but as general concepts.
...
What is the equivalent "servlet code" for this:
<jsp:useBean id="user" class="beans.UserBean" scope="session"/>
<jsp:setProperty name="user" property="*"/>
Tomcat translates this to:
beans.UserBean user = null;
synchronized (session) {
user = (beans.UserBean) _jspx_page_context.getAttribute("user", PageContext.SESSION_SCOPE);
...
Two semesters ago, I had a professor who said:
Some of you have been told to always include setter and getter methods for all private instance variables. I say that this breaks information hiding, and often results in systems where invariants cannot be enforced.
Now, that sounds right to me. But isn't including those kinds of sett...
I have a couple of probably common thoughts on JavaServer Faces (JSF) which I want to clear up.
Is it possible to just add a Java Class and Call methods inside it from a JSF (x) Page?
I can't see how this even could be an issue knowing to do when you program Java and develop webapplications. However, I can't seem to find a concrete a...
By default, eclipse generates getters/setters according to JavaBeans regular properties style:
* public void setName(String name)
* public String getName()
As of J2SE 5.0 JavaBeans specification allows IndexedPropertyChangeEvents which have a different getter/setter naming scheme for arrays:
* public void setName(int index, String n...
Is this the appropriate way to access bean properties of an Object without knowing/caring about its exact type? (Or is there a built-in method that does this already?) Is there an appropriate exception to throw when a property does not exist or is not available?
static private Object getBeanPropertyValue(Object bean, String propertyName...
Hello,
I'm working on a project using iBatis and a Java caching tool ehcache but I'm implementing the model classes in Scala. I'm having a stong feeling that I'll have to override the equals and hashCode methods to enable the cache easily manage objects on it.
Since most of the required properties in the scala classes are vars, I need ...
I have a Servlet which is called upon an Action and this Servlet is suppose to return a List of Objects. Now by having the Data Structure at the end of my Post my Servlet calls the Person.fetch() which returns an list/array of Persons.
I want my Java Server Face to iterate through this list and call the getPresentation method on each ob...
(For those who read my previous question, this is the same teacher and the same project.)
My teacher 'inspected' my code for a web application project and provided some suggestions. One of the suggestions was to use the this keyword even in this situation:
private String getUsername() {
return username;
}
So if I follow his advic...
I recently wrote some data access methods (plain old Java) that use immutable objects for both the request objects and the resulting data objects. I like the immutable objects because they prevent a good deal of confusion from appearing in the client code which I've seen in the past when people attempt to mutate and reuse objects.
Anyw...
I'll try to explain my problem as clear as possible :). I am using PropertyChangeSupport to notify registered views for changes in the properties. One of the property is an object which properties are changed every view seconds. I don't want to create for this particular object new instance every time it is being updated (for the propert...
Have seen some similar questions here and here.
Can you also please tell me the contexts in which they are used?? Or the purpose of them?
...
I want to populate data into one bean using a regular POJO. In order to get that data later, do I have to pass the reference to that bean around my code till I want to use it?
Do I save that reference to a Session object? (not sure if that even makes sense)
What is the best pattern to use for such a situation.
...
The Java Bean web call is like this
@WebMethod
public void updateComment(
@WebParam(name="Id") int Id,
@WebParam(name="comment") String comment)
{
funct().updateComment(Id, comment);
}
After binding to the web service in visual studio, the call works fine unless you try to pass a null for the string commen...
Hi ,
What is a java bean ..why do i need it .since i can solve all apps with my class and interface structure. Why do i need beans.And can you point me a place where beans are essential instead of class and interface?
Please explain the essentiality of a bean in the below context:
Wep apps
Standalone Apps
...
This question is close, but still not what I want. I'd like to assert in a generic way that two bean objects are equivalent. In case they are not, I'd like a detailed error message explaining the difference instead of a boolean "equal" or "not equal".
...
I am creating a simple reporting program using java and iReport (from jasper), which is supposed to create a report in pdf showing PCs with their IP address, their location, whether it's idle or not at the moment (handled by another system), and a list of projects it is currently attached to (managed elsewhere, too).
I'm using iReport f...
Hi people!
I am trying to write a JavaBean to be used in a JSP, such that when a user writes the url to an external website the bean filters the page before displaying it to the user.
Now what I tried to do till now is to download the page using an HTTPUrlConnection, does the filtering, saves the filtered html inside a temporal local h...
I have an assignment to use JavaBeans to create an online Banking application. I am trying to make the signup form but I am having some issues. When the form submits I am not able to get the values.
The Form:
<jsp:include page="header.html"></jsp:include>
<h3>Create An Account</h3>
<form action="process_new_user_account.jsp" metho...