Re: [Stripes-users] Preserving unbound values on save

2014-11-26 Thread Dave Roberge
William Krick  writes:

> This has to be a common problem.  Ideally, I'd like to have something 
where unbound members of the customer object are just left with their 
original values.  Short of maintaining two separate Customer objects, 
one for the screen and one for the database and juggling data back and 
forth between the two, is there a way to deal with this situation?

Hey, I think this is what you're looking for, 
http://stripes.sourceforge.net/docs/current/javadoc/net/sourceforge/strip
es/action/StrictBinding.html 



--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users


Re: [Stripes-users] Preserving unbound values on save

2014-11-26 Thread Dave Roberge
Hey, I think this is what you're looking for, 
http://stripes.sourceforge.net/docs/current/javadoc/net/sourceforge/stripes/action/StrictBinding.html

From: William Krick [kr...@3feetunder.com]
Sent: Wednesday, November 26, 2014 6:19 PM
To: Stripes Users List
Subject: [Stripes-users] Preserving unbound values on save

I have a situation where I have a JSP form and it is populated with values from 
an object pulled from a database.

Below is some sample code off the top of my head.  It might not compile.  The 
names have been changed to protect the innocent.

The problem I'm having is that the Customer object contains a lot more fields 
than are displayed on the page for the user to edit.  And when the user saves 
the page, anything not explicitly named on the page and bound to the customer 
object in the action bean gets set to null.

I know that I can add hidden tags on the page as a way to deal with this, but 
there's a lot of extra un-bound fields in the Customer object, and I really 
don't want to add a bunch of hidden tags.  Plus, this exposes the data in those 
fields to any user who views the source on the html page.

The Customer object was designed to mirror the database model, but the user 
view into that model isn't 100% of the data.

This has to be a common problem.  Ideally, I'd like to have something where 
unbound members of the customer object are just left with their original 
values.  Short of maintaining two separate Customer objects, one for the screen 
and one for the database and juggling data back and forth between the two, is 
there a way to deal with this situation?



public class EditCustomerAction extends BaseAction {

private Long customerId;
private Customer customer;

@DefaultHandler
public Resolution view() {
if (customerId != null) {
customer = CustomerClient.getInstance().retrieveCustomer(customerId);
}
return new ForwardResolution(EDIT_CUSTOMER_JSP);
}

public Resolution save() {
if (customer != null && customerId != null) {
CustomerClient.getInstance().updateCustomer(customerId, customer);
}
return new RedirectResolution(NEXT_JSP);
}

public Resolution cancel() {
return new RedirectResolution(PREV_JSP);
}

public Long getCustomerId() { return customerId; }

public void setCustomerId(Long customerId) { this.customerId = customerId; }

public Customer getCustomer() { return customer; }

public void setCustomer(Customer customer) { this.customer = customer; }

}

--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk___
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users