[Wicket-user] Back Button DropDownChoice

2006-12-27 Thread Andrew Strickland
I have a class that extends DropDownChoice, called TCOChooser.  It is for some 
very minor things (overriding wantOnSelectionChanged, the choice renderer, etc 
).  I have a page that uses TCOChooser to allow the user to select a TCO that 
changes the data displayed in a table lower on the page.
 
When the user selects a new TCO the table updates as expected. When I use the 
back button on the browser the table reverts as expected.  However, the 
TCOChooser does not revert, and stays with the last user selected value.
 
My question is, am I doing something wrong or unexpected here or is this a 
problem with Wicket's modelChanged and versioning strategy or perhaps even a 
limitation of the browser or the html select element?
 
Below is TCOChooser:
 
public class TCOChooser extends DropDownChoice{

private OrderPage orderPage;

public TCOChooser(String id, IModel model, List choices, OrderPage 
orderPage){
super(id, model, choices, new TCOChoiceRenderer());

this.orderPage = orderPage;
}

protected boolean wantOnSelectionChangedNotifications() {
return true;
}

protected void onSelectionChanged(final Object newSelection) {
orderPage.updateOrderTable((TCO)newSelection);
}
}
 
 
 
Below is my page ( OrderPage ):
 
 
public class OrderPage extends WebPage {

DataTable orderTable;

DropDownChoice tcoChooser;

TCO TCO;

/**
 * Creates a new instance of OrderPage.  TCO will be null and the entire
 * list of AbstractOrder(s) will be returned.
 */
public OrderPage() {

}

/**
 * Creates a new instance of OrderPage.  The AbstractOrder(s) that match
 * the TCO will be returned.
 *
 * @param TCO The TCO to filter the list of AbstractOrder(s) by.
 */
public OrderPage(TCO TCO){
this.TCO = TCO;
}

private void initTCOChooser(){
List tcos = new TCODAO().getTCOs();

/* If the TCO was not supplied through the constructor, default to the 
first item in the TCO drop down */
if( TCO == null ){
TCO = (TCO)tcos.get(0);
}

tcoChooser = new TCOChooser(tcoChoices, new Model(TCO), tcos, this);
add(tcoChooser);
}

private void initOrderTable(){
List columns = new ArrayList();
columns.add(new PropertyColumn(new Model(TSR Number), 
TSRNumber.number, TSRNumber.number));
columns.add(new PropertyColumn(new Model(TSO Number), 
TSONumber.number, TSONumber.number));
columns.add(new PropertyColumn(new Model(CCSD), CCSD.number, 
CCSD.number));
orderTable = new DefaultDataTable(orders, columns, new 
OrderDataProvider(TCO), 25);
add(orderTable);
}

@Override
protected void onAttach() {

if(tcoChooser==null){
initTCOChooser();
}
   

if( orderTable == null ){
initOrderTable();
}
}

/*
 * A public callback to allow the TCOChooser component to update the order 
table when a new TCO selection is made.
 *
 * @param TCO The TCO to limit the orders in the table to.
 */
public void updateOrderTable(TCO TCO){
this.TCO = TCO;
 
remove(orderTable);
initOrderTable();
}
}
 
Thanks much,
Andy Strickland
winmail.dat-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


[Wicket-user] RE: combo box displaying choose one

2006-05-31 Thread Andrew Strickland



If you call setNullValid(true) the default "null" value will be an empty string instead of "Choose One"

Andy

"When I reach with the selection in a combo box, to the first item in the list, wicket places a "Choose one" option as the first item in the combo. Am I doing something wrong or ... does anybody know how to avoid this ? "




[Wicket-user] RE: Resetting a Form

2006-04-27 Thread Andrew Strickland



At wit's end here so I'm going to post my code. Can't for the life of me figure out why the form won't reset, even when I re-initialize the underlying model object.

Code follows:

AccountPage.java

public class AccountPage extends DefaultPage{ /* The user to edit, or null (for a new user) */ private User user;
 public AccountPage(PageParameters parameters) { super("Account");
 String accountId = parameters.getString("accountId");
 User theUser = UserProvider.getInstance().getUserByAccountID(accountId);

 /* The is a new account, new up a User as our Model object */ if (theUser == null) { theUser = new User(); }

 setUser(theUser);
 addInstructions();
 addAccountPanel(); }

...

public void addAccountPanel() { add(new AccountPanel("accountPanel", this)); }

AccountPanel.java

public AccountPanel(String id, AccountPage accountPage) { super(id);

 this.accountPage = accountPage;

 model = new BoundCompoundPropertyModel(accountPage.getUser());

 propertyModel = new PropertyModel(accountPage.getUser(), RequiredFieldContainer.CLASSIFIED_ACCOUNT_TYPE);

 accountForm = new Form("accountForm", model);

 add(accountForm);

...

down in the submit button's onSubmit (still inside AccountPanel.java)...

Button submitButton = new Button("submitButton", new Model()) { protected void onSubmit() { /* * See below comment in the cancel button concerning the null * response page */ cancelResponsePage();
 /* * If user already exists, update the user. Otherwise create the * user. */
 if (UserProvider.getInstance().userExists(accountPage.getUser())) { UserProvider.getInstance().updateUser(accountPage.getUser(), true);
 resetForm();
 getPage().getResponse().redirect( (String)accountPage.getWp2fSession().getHttpSession() .getAttribute(SessionConstants.ORIGINAL_REFERRER)); } else {
 UserProvider.getInstance().addUser(accountPage.getUser()); /* * Reprint, review, whatever. Shows instructions, pops up the * SAAR. */
 String response = "/reprintUserRegistration.jsp?token=" + accountPage.getUser().getToken() + "accountType=" + accountPage.getUser().getAccountType();
 resetForm();
 getPage().getResponse().redirect( accountPage.getContextPath() + response); } } };

...

/** * Reset the model of the page, form, etc. *  * Subsequent visits to the page should show up with no data already entered. */ private void resetForm() { User user = new User();
 model = new BoundCompoundPropertyModel(user);
 accountForm.setModel(model);
 }



Any insight would be much appreciated :)

Andy


[Wicket-user] RE: Resetting a Form

2006-04-27 Thread Andrew Strickland





That PropertyModel is used inside some custom FormComponents that I have that do their own logic on whether to add the RequiredValidator or not depending on the Boolean object returned from the binding RequiredFieldContainer.CLASSIFIED_ACCOUNT_TYPE which is the isClassifiedAccountType method from the User object.

I make a new model because if I just set the model object it causes an OGNL exception because their is no property of the User called "accountForm".

I think after stepping through with a debugger the problem is not actually in Wicket at all, but in some of our own persistance logic.

Andy

what is that propertyModel = new PropertyModel(accountPage.getUser(),RequiredFieldContainer.CLASSIFIED_ACCOUNT_TYPE);

where is that model used?

and why are you making a new model why net =just set the model object on the form itself?

form.setModelObject(user)

johan





[Wicket-user] RE: Resetting a Form

2006-04-26 Thread Andrew Strickland
Title: Wicket-user digest, Vol 1 #2423 - 3 msgs



How would I go about resetting a form to a blank state after it validates it's data and stores it to a database? Subsequent visits to the Page the form is on still contains the data from the last submission.

I tried re-initializing the object that backs the BoundCompoundPropertyModel but that didn't seem to work.


TheFormComponent(s)inherit their model from the BoundCompoundPropertyModel of the Panel they are on, which in turn getsthe model object from the Page.

Andy


---
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk0709&30571642
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


[Wicket-user] RE: Resetting a Form

2006-04-26 Thread Andrew Strickland



Would that answer be relevant for 1.2 or is this something that should be working in 1.1.1? I can't seem to get that to work.

AndyBean bean=3Dnew Bean();Form.setModelObject(bean);where bean is the bean backing the form, and form has the compound model,-IgorOn 4/26/06, Andrew Strickland [EMAIL PROTECTED] wrote: How would I go about resetting a form to a blank state after it validate=s it's data and stores it to a database? Subsequent visits to the Page the form is on still contains the data from the last submission. I tried re-initializing the object that backs the BoundCompoundPropertyModel but that didn't seem to work. The FormComponent(s) inherit their model from the BoundCompoundPropertyModel of the Panel they are on, which in turn gets t=he model object from the Page. Andy


[Wicket-user] RE: Removing a Validator

2006-04-25 Thread Andrew Strickland
My apologies for leaving all that reply text in my last response.  Hopefully it 
doesn't confuse anyone too much.
 
Andy
winmail.dat

[Wicket-user] RE: Removing a Validator

2006-04-25 Thread Andrew Strickland



My first thought was the component would have a Map of validators that you storeby a validator name...that way you could add or remove like remove( IValidator.getName() )...also that way you could never end up with more than one of the same type of Validator on any given component.

AndyHow would you remove the validator? Would you do it by index or by instance?Its not very clean either way. Check out IFormValidator, I think it fitsyour usecase better then an IValidator.-IgorOn 4/25/06, Andrew Strickland [EMAIL PROTECTED] wrote: Was the capability added in 1.2 to remove Validators from a component? I=f not, are there any plans to add such a capability? When doing dynamic forms it is a huge convenience to be able to add and remove validators based on a user selection on another field in the form. An example: on my project some fields are required or not depending on th=e classification of the system. During account creation the user has the ability to choose which classification they are requesting their account =be created for. If they choose the more restrictive classification and then change their mind and switch to the less restrictive some of the fields t=hat I added a validator to will now STILL have the RequiredValidator even tho=ugh it is no longer a required field, and I have no way of removing the validator. Andy