Win a copy of Java by Comparison (eBook) this week in the Java in General forum!

Brian Nice

Ranch Hand
+ Follow
since Nov 02, 2000
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Brian Nice

Sorry, this is probably really basic, but I'm just starting out. As a simple example, if i have a page that has a name input field, along with a button that is for a different bean:



In the controller:



I forsee us having multiple beans that back one page, and then a controller class that needs access to all those beans. Thanks for the help
Brian
10 years ago
JSF
What is the difference between the Basic and Standard jsf components that NetBeans 5.5 offers you when creating a the Visual Web application? The Basic use the tag library prefixed by webuijsf, and the other uses the prefix h. I haven't found any documentation distinguishing the two. Thanks
Brian
What is the difference between the Basic and Standard jsf components that NetBeans 5.5 offers you when creating a the Visual Web application? The Basic use the tag library prefixed by webuijsf, and the other uses the prefix h. I haven't found any documentation distinguishing the two. Thanks
Brian
11 years ago
JSF
I am developing a website that has a news article on the front page. Usually it would contain a few lines of the story and have a [More...] link to link to the fulls story.

If I get a new story coming in that replaces the original story, I would like to take only a couple lines from the original story and put it on the right sidebar, with a [More...] link where they can get the full story. After a while, that story would roll off, but the user would be able to get back to the story by looking at a history of previously posted stories. It is a pretty common thing I think.

What is the best way to manage that such that I don't have to duplicate typing in the few lines when it is on the front page, the couple of lines on the sidebar, and the full story? Do people use some sort of content management system?

Thanks for the insight
Brian
[ March 23, 2006: Message edited by: Brian Nice ]
I ended up writing a custom property editor that seems to do the job. It is specific for int fields, it would be nice to extend it to handle any type of primitive. Thanks for the reply
Brian
Check out this link:

http://www.oreilly.com/catalog/javaxslt/chapter/ch05.html

You can use a SAX content handler to read from a file and fire off events to an XSL transformer that can turn it in to an XML file. I haven't done this in a while, but it works pretty good.

HTH,
Brian
Have you looked at JaxB, it is relatively easy to convert a java object to XML which you could then easily transform to another xml format using xsl. Another similar technology would be Jibx, it pretty much does the same thing as JaxB but it's a little faster and possibly simpler.

Brian
If you go to the Manning publication site, it will show you the different chapters, and also has a couple of sample chapters that you can read.

www.manning.com

Brian
I have a Player object that holds on to an address. When I retrieve the Player object from the database, it doesn't automatically retrieve the Address objects associated to it. What is the correct way to enable eager fetching for an object such that I don't have to do something like

Player p = ... retrieve from database ...
p.getAddress().getCity(); // force load of address object by referencing it

Thanks
Brian
What is the best way to bind an input form on a web page to a primitive type in an object? Say you have an input form where someone types in an age, and that age is stored as an int in my object. If I type a value in the form field, it binds correctly to the int field in my object.

However, if I leave my form field blank and press submit, it complains that it cannot convert string to int.

Is the way to handle this by providing a custom property editor, or is the preferred way to manually get that form parameter from the HttpServletRequest and populate the object?

Thanks for the help
Brian
Found the answer in another post, didn't look long enough. The unsave-value I had on my class definitions was using null, which was not correct since my ids were ints. I changed to unsave-value="0" and it worked!
I have a Player object that holds on to an Address object and use a many-to-one mapping as follows:



when I save my Player object, I want it to save the address object, hence the cascade="all" in the Player mapping. However the SQL that it generates is:



Why is it trying to do an update on the address object instead of an insert? Is there something I need to correct in the mapping?

Thanks for the help
Brian
I didn't realize until this morning that BindException was actually a subclass of Errors so I can use the same way of adding errors as I am doing in my Validator.
Brian
In the SimpleFormController, the onSubmit takes a BindException as a parameter. How do I add a new error to that object? For example, I have a service that validates a username and password against a value, and if they do not match I want to display an error back to the user. Is the following the correct way to do this or is there a more elegant way to do this?



Thanks for the help
Brian
The problem was in my persistent class, I had typed the set field incorrectly. Doh!

private Long id;
public void setId(Long Id) {
this.id = id;
}

Thanks
Brian