Fwd: Feedback Messages prevent DropDownChoice updating Textfields

2014-02-11 Thread Daniela L
Hi,
I am trying to implement a Feedback for every Form Component and
a catch all Feedback Panel in wicket 6.12.0. Everything works fine except
for the case
when a user causes a error which is shown in the Feedback Panel of the
Component,
e.g. the Textfield firstName is left empty. After that the select of the
DropDownChoice
does not update the Textfields anymore. Where is my mistake? Thanks a lot
in advance.
Daniela

Here is my code:

public class EditEmployeePage extends BasePage {
private FormComponentString firstName;
private DropDownChoiceEmployee employeeDDC;
private final FormEmployee employeListForm;
private ModelEmployee employeeModel;
private Employee employee;
@SpringBean(name=employeeService)
private EmployeeService employeeService;
private Button saveEmployeeButton;
private Button resetButton;

public EditEmployeePage(final PageParameters parameters) {
super();
employee = new Employee();
employeeModel = new ModelEmployee(employee);//for dropDownChoice
final CompoundPropertyModelEmployee employeeCpm = new
CompoundPropertyModelEmployee(employeeModel); //for form
employeListForm = new FormEmployee(employeListForm,
employeeCpm);
employeListForm.setOutputMarkupId(true);
add(employeListForm);
addEmployeeDropDown();
addFirstNameTextField();
//more fields
 }

private void addEmployeeDropDown() {
Label chooseEmployeeLabel = new Label(chooseEmployeeLabel,
Mitarbeiter wählen:*);
employeListForm.add(chooseEmployeeLabel);

// Employee DropdownChoice
LoadableDetachableModelListEmployee employeeValueChoices = new
LoadableDetachableModelListEmployee() {
private static final long serialVersionUID = 1L;

protected ListEmployee load() {
ListEmployee employees = Collections.emptyList();
employees = employeeService.findallEmployees(getCompany());
if (!employees.isEmpty()){
employeeModel.setObject(employees.get(0));
}
return employees;
}

};

employeeDDC = new DropDownChoiceEmployee(employee,
employeeModel,
employeeValueChoices.getObject(),
new TwoPropertiesChoiceRendererEmployee(employeeId,
lastName, firstName, ,));
employeeDDC.setLabel(new ModelString(Mitarbeiter
wählen));
employeeDDC.add(new
AjaxFormComponentUpdatingBehavior(onchange) {
@Override
protected void onUpdate(AjaxRequestTarget target) {
   target.add(employeListForm);
}
  });

employeeDDC.setRequired(true);
employeListForm.add(employeeDDC);
}

private void addFirstNameTextField() {
// first name label and field on page
Label firstNameLabel = new Label(firstNameLabel, Vorname:*);
employeListForm.add(firstNameLabel);
firstName = new TextFieldString(firstName);
firstName.setLabel(new ModelString(Vorname));
firstName.setOutputMarkupPlaceholderTag(true);
FeedbackPanel firstNameFeedback =  (FeedbackPanel) new
FeedbackPanel(firstNameFeedback, firstName).setOutputMarkupId(true);
employeListForm.add(firstNameFeedback);
employeListForm.add(firstName);
firstName.setRequired(true);
}
...
}

public abstract class BasePage extends WebPage {
   private final FeedbackPanel pageFeedback = new
FeedbackPanel(feedback);
   public BasePage() {
  super();
  pageFeedback.setOutputMarkupId(true);
  add(pageFeedback);
   }


Submitting values for null associations

2014-02-11 Thread ChambreNoire
Hi,

I have a form which can flip between edit and view modes. Its fields share a
common CompoundPropertyModel which in turn points to an AbstractEntityModel
similar to that described in the 'Wicket in Action' blog. 

My problem is with associations that happen to be null. If I have a User
entity with a lazily initialised Job association, during viewing all works
fine but when I edit the user and enter some text into a field that is bound
to User.Job.Name I get a WicketRuntimeException: Attempted to set property
value on a null object. How is this kind of situation generally handled?

Many thanks,

Chambre

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Submitting-values-for-null-associations-tp4664365.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Submitting values for null associations

2014-02-11 Thread francois meillet
The entity User needs to have a Job's instance when you construct your
model.

François


On Tue, Feb 11, 2014 at 2:56 PM, ChambreNoire a...@tentelemed.com wrote:

 Hi,

 I have a form which can flip between edit and view modes. Its fields share
 a
 common CompoundPropertyModel which in turn points to an AbstractEntityModel
 similar to that described in the 'Wicket in Action' blog.

 My problem is with associations that happen to be null. If I have a User
 entity with a lazily initialised Job association, during viewing all works
 fine but when I edit the user and enter some text into a field that is
 bound
 to User.Job.Name I get a WicketRuntimeException: Attempted to set
 property
 value on a null object. How is this kind of situation generally handled?

 Many thanks,

 Chambre

 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/Submitting-values-for-null-associations-tp4664365.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: How to implement an auto-save behavior

2014-02-11 Thread Boris Goldowsky
Thank you Martin, that works like a charm.

Boris


On Feb 10, 2014, at 2:27 PM, Martin Grigorov mgrigo...@apache.org wrote:

 Hi,
 
 To submit a form all you need to provide to the object you pass to
 Wicket.Ajax.ajax() is the 'f' attribute:
 Wicket.Ajax.post({ u: 'url/to/AjaxFormSubmitBehavior', f: 'formId', sc:
 'optionalSubmittingComponentId'});
 
 I will update the Ajax chapter in the Reference guide soon to explain the
 JS API.
 
 Martin Grigorov
 Wicket Training and Consulting
 
 
 On Mon, Feb 10, 2014 at 5:48 PM, Ernesto Reinaldo Barreiro 
 reier...@gmail.com wrote:
 
 Is not a function? If I look at the source code I see something like
 
 submitMultipartForm = function(context) {
 
 },
 
 
 
 
 On Mon, Feb 10, 2014 at 5:41 PM, Boris Goldowsky bgoldow...@cast.org
 wrote:
 
 Thanks, but that also results in Wicket.Ajax.Call.submitMultipartForm is
 not a function.
 
 I suspect the answer is to get the parameters set up correctly and then
 arrange for the result of getCallbackScript() to be called periodically.
 If someone else has done something like this and has a working example
 that would be really helpful.
 
 Boris
 
 
 
 On Feb 10, 2014, at 11:08 AM, Ernesto Reinaldo Barreiro 
 reier...@gmail.com wrote:
 
 Maybe Wicket.Ajax.Call.subitMultipartForm?
 
 
 On Mon, Feb 10, 2014 at 4:56 PM, Boris Goldowsky bgoldow...@cast.org
 wrote:
 
 I'm attempting to migrate an auto-saving behavior from wicket 1.5 to
 wicket 6.  In wicket 1.5 it worked by doing something like this every
 30
 seconds to loop through auto-save-enabled forms on the page and submit
 them:
 
 $(form.ajaxAutoSave).each(function() {
 var form = $(this);
 wicketSubmitFormById(form.attr('id')...)
 }
 
 The AJAX migration documentation -
 https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax -
 suggests
 replacing Wicket.submitFormById with Wicket.Ajax.submitForm , but this
 method does not appear to exist:  replacing the above code with
 
 $(form.ajaxAutoSave).each(function() {
 var form = $(this);
 //unsure of expected params so just picked one from the migration
 documentation
 Wicket.Ajax.submitForm({f:form.attr('id')});
 }
 
 When the function is called I can see the following error in the
 console:
 
 Uncaught TypeError: Object # has no method 'submitForm'
 
 So I went into the console and I can see that Wicket.Ajax is defined,
 but
 Wicket.Ajax.submitForm is not.
 
 Is the documentation incorrect here, or is there some additional step
 to
 take to gain access to the submitForm method?
 
 Alternatively - is there a better way to create an auto-save behavior?
 AjaxFormSubmitBehavior would appear to almost meet the need, if there
 is a
 way to  tie it to a timer-generated event.
 
 Boris
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 
 
 --
 Regards - Ernesto Reinaldo Barreiro
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 
 
 --
 Regards - Ernesto Reinaldo Barreiro
 


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Submitting values for null associations

2014-02-11 Thread ChambreNoire
Yes I'm aware of this but the problem is I'm reusing the same
AbstractEntityModel (effectively a LoadableDetachableModel that loads from
the db) for the edit mode and the User instance in the db has no Job
instance (yet). I could always re-build a Model using the unproxied User
instance when I flip from view to edit but then all the child form
components would need to be reassigned as I'm not rebuilding the view...

Chambre

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Submitting-values-for-null-associations-tp4664365p4664368.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Submitting values for null associations

2014-02-11 Thread ChambreNoire
I forgot to mention, the reason I don't systematically make a new Job
instance is that when saving the form hibernate creates a new Job instance
which is effectively empty if no Job details have been input.

Chambre

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Submitting-values-for-null-associations-tp4664365p4664369.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Submitting values for null associations

2014-02-11 Thread francois meillet
As Hibernate save a new Job instance when you save the User if the relation
is empty
why don't you load the job (with an eager fetching strategy) when you load
the user ?

François


On Tue, Feb 11, 2014 at 3:22 PM, ChambreNoire a...@tentelemed.com wrote:

 I forgot to mention, the reason I don't systematically make a new Job
 instance is that when saving the form hibernate creates a new Job instance
 which is effectively empty if no Job details have been input.

 Chambre

 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/Submitting-values-for-null-associations-tp4664365p4664369.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: Submitting values for null associations

2014-02-11 Thread ChambreNoire
Why would that make any difference? A null Job is still a null Job. Unless
I'm missing something...

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Submitting-values-for-null-associations-tp4664365p4664371.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Submitting values for null associations

2014-02-11 Thread francois meillet
You use cascade=all on the job relation.
When job is created, it should have at least one non-empty property.
Job's instance is null because it doesn't have any non empty property.

François


On Tue, Feb 11, 2014 at 3:59 PM, ChambreNoire a...@tentelemed.com wrote:

 Why would that make any difference? A null Job is still a null Job. Unless
 I'm missing something...

 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/Submitting-values-for-null-associations-tp4664365p4664371.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: Submitting values for null associations

2014-02-11 Thread ChambreNoire
I'm afraid I still don't see it. I think I'm just going to have to use a
nested model at the form level and rebuild it whenever I toggle
viewing/editing mode. So I'd build a new Model() from the unproxied User
when switching to edit mode and build a new
AbstractEntityModelUser(user.id, User.class) when switching to viewing.
I'd also have to check for empty associations and null then upon saving so
as not to have empty associations (rows with just an id) in the db. Seems
rather painstaking but I can think of a better way atm...

Chambre

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Submitting-values-for-null-associations-tp4664365p4664373.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



How get wiki Framework Documentation for offline reading

2014-02-11 Thread Farrukh SATTOROV
Hi everyone!, Can i download wicket wiki framework documentation for
offline reading. Thanks.
https://cwiki.apache.org/confluence/display/WICKET/Index


How to make a Wiket DropDownChoice with complex a model return a simple String

2014-02-11 Thread Bruce Lombardi
To make this easier to understand, let's say that I have a list of state
abbreviations for example AL, AK, AZ, AR etcetera (the actual example has
two letter abbreviations also, but much longer names). I need a
DropDownChoice that shows the abbreviations for selection (e.g., AK) but
will show the full name as a tooltip whenever the mouse hovers over one of
the choice (e.g., AK shows Alaska). 

 

I have developed a solution that is based on the example presented here:
http://stackoverflow.com/questions/12234738/wicket-dropdownchoice-titles-too
ltips-for-options

that develops a subclass of DropDownChoice and overrides  appendOptionHtml
to append a title to the buffer. My class takes a StateDisplay object as
its model, and the model has two fields, an id that is displayed in the
list, and a fullName which is added as the title by the appendOptionHtml
method.

 

This works fine for displaying thedropdown with the  tooltip, but the
problem is that the model is a complex object( StateDisplay) with two
fields, but the underlying domain object needs a simple String with the
state ID.

 

Prior to implementing the tooltip, the DrowdownChoice was formed using:

 

Item.add(new DropDownChoiceString(state, new
PropertyModelString((CompanyDTO) item.getDefaultModelObject(), state),
stateList)));

 

Note: item is there because this is used in the populateItem method of a
ListView.

 

Now the code is:

 

Model StateDisplay  selectedState = new Model();

 

ChoiceRendererStateDisplay choiceRenderer = new
ChoiceRendererModifierDisplayDto(id, id);

   

Item.add(new StateDropDownChoice StateDisplay (state, selectedState,
stateList, choiceRenderer));

 

After the selection is made the model (selectedState) is set to the chosen
StateDisplay, but there is no easy way to the simple String value set on
the CompanyDTO.

 

How can I make the dropdown selection update the domain model's simple
String.

 

Thanks

Bruce



Re: How get wiki Framework Documentation for offline reading

2014-02-11 Thread Martin Grigorov
http://wicket.apache.org/guide/guide/single.pdf

Martin Grigorov
Wicket Training and Consulting


On Tue, Feb 11, 2014 at 6:06 PM, Farrukh SATTOROV fireda...@gmail.comwrote:

 Hi everyone!, Can i download wicket wiki framework documentation for
 offline reading. Thanks.
 https://cwiki.apache.org/confluence/display/WICKET/Index



SpringBean and properties file.

2014-02-11 Thread Entropy
I think this is a problem in spring and wicket working together.  This is in
1.4.7.  

In spring:
bean id=portalResources
class=gov.usdoj.afms.afmsportal.application.AFMSPortalResources
init-method=init scope=singleton
property name=portalService ref=portalService/
property name=env value=${environment} /
property name=version value=${version} /
property name=localDev value=${localdev} /
property name=production value=${production} /
property name=localDevUserName value=${localdev_username} 
/
/bean

This bean is injected into a wicket page with @SpringBean.  Using
breakpoints I can see spring insantiating this bean, and setting the
properties.  The values are there.  This happens on application startup.  

But when I got to get the injected bean, the constructor fires again, but
the init method and the setting or properties are NOT called, and despite
the scope=singleton, a second completley different instance is being
instantiated and injected.  And it's empty, which is no good.

Any ideas on this?

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/SpringBean-and-properties-file-tp4664377.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: How get wiki Framework Documentation for offline reading

2014-02-11 Thread Farrukh SATTOROV
I have printed this guide as brochure and reading now, but i mean about
wiki doc. Thanks anyway


On Tue, Feb 11, 2014 at 10:52 PM, Martin Grigorov mgrigo...@apache.orgwrote:

 http://wicket.apache.org/guide/guide/single.pdf

 Martin Grigorov
 Wicket Training and Consulting


 On Tue, Feb 11, 2014 at 6:06 PM, Farrukh SATTOROV fireda...@gmail.com
 wrote:

  Hi everyone!, Can i download wicket wiki framework documentation for
  offline reading. Thanks.
  https://cwiki.apache.org/confluence/display/WICKET/Index
 




-- 
С уважением и наилучшими пожеланиями
*Фаррух*


Re: How get wiki Framework Documentation for offline reading

2014-02-11 Thread Martin Grigorov
The Wiki is not very up-to-date...

Martin Grigorov
Wicket Training and Consulting


On Tue, Feb 11, 2014 at 8:48 PM, Farrukh SATTOROV fireda...@gmail.comwrote:

 I have printed this guide as brochure and reading now, but i mean about
 wiki doc. Thanks anyway


 On Tue, Feb 11, 2014 at 10:52 PM, Martin Grigorov mgrigo...@apache.org
 wrote:

  http://wicket.apache.org/guide/guide/single.pdf
 
  Martin Grigorov
  Wicket Training and Consulting
 
 
  On Tue, Feb 11, 2014 at 6:06 PM, Farrukh SATTOROV fireda...@gmail.com
  wrote:
 
   Hi everyone!, Can i download wicket wiki framework documentation for
   offline reading. Thanks.
   https://cwiki.apache.org/confluence/display/WICKET/Index
  
 



 --
 С уважением и наилучшими пожеланиями
 *Фаррух*



Re: SpringBean and properties file.

2014-02-11 Thread Sven Meier

Hi,

Wicket uses CGLib proxies, to proxy beans which are not referenced by 
their interface.

This leads to the constructor being fired once for each injection.

If you don't want this, declare the type of the @SpringBean member as an 
interface.


Sven



On 02/11/2014 08:46 PM, Entropy wrote:

I think this is a problem in spring and wicket working together.  This is in
1.4.7.

In spring:
bean id=portalResources
class=gov.usdoj.afms.afmsportal.application.AFMSPortalResources
init-method=init scope=singleton
property name=portalService ref=portalService/
property name=env value=${environment} /
property name=version value=${version} /
property name=localDev value=${localdev} /
property name=production value=${production} /
property name=localDevUserName value=${localdev_username} 
/
/bean

This bean is injected into a wicket page with @SpringBean.  Using
breakpoints I can see spring insantiating this bean, and setting the
properties.  The values are there.  This happens on application startup.

But when I got to get the injected bean, the constructor fires again, but
the init method and the setting or properties are NOT called, and despite
the scope=singleton, a second completley different instance is being
instantiated and injected.  And it's empty, which is no good.

Any ideas on this?

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/SpringBean-and-properties-file-tp4664377.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: How to make a Wiket DropDownChoice with complex a model return a simple String

2014-02-11 Thread Andrea Del Bene

Hi,

I needed something similar in a couple of projects. One solution is to 
create a custom DropDownChoice which takes also the string model to 
update. Then you can override onModelChanged to update the string model 
with the new value that can be extracted with the ChoiceRenderer.

To make this easier to understand, let's say that I have a list of state
abbreviations for example AL, AK, AZ, AR etcetera (the actual example has
two letter abbreviations also, but much longer names). I need a
DropDownChoice that shows the abbreviations for selection (e.g., AK) but
will show the full name as a tooltip whenever the mouse hovers over one of
the choice (e.g., AK shows Alaska).

  


I have developed a solution that is based on the example presented here:
http://stackoverflow.com/questions/12234738/wicket-dropdownchoice-titles-too
ltips-for-options

that develops a subclass of DropDownChoice and overrides  appendOptionHtml
to append a title to the buffer. My class takes a StateDisplay object as
its model, and the model has two fields, an id that is displayed in the
list, and a fullName which is added as the title by the appendOptionHtml
method.

  


This works fine for displaying thedropdown with the  tooltip, but the
problem is that the model is a complex object( StateDisplay) with two
fields, but the underlying domain object needs a simple String with the
state ID.

  


Prior to implementing the tooltip, the DrowdownChoice was formed using:

  


Item.add(new DropDownChoiceString(state, new
PropertyModelString((CompanyDTO) item.getDefaultModelObject(), state),
stateList)));

  


Note: item is there because this is used in the populateItem method of a
ListView.

  


Now the code is:

  


Model StateDisplay  selectedState = new Model();

  


ChoiceRendererStateDisplay choiceRenderer = new
ChoiceRendererModifierDisplayDto(id, id);




Item.add(new StateDropDownChoice StateDisplay (state, selectedState,
stateList, choiceRenderer));

  


After the selection is made the model (selectedState) is set to the chosen
StateDisplay, but there is no easy way to the simple String value set on
the CompanyDTO.

  


How can I make the dropdown selection update the domain model's simple
String.

  


Thanks

Bruce





-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Submitting values for null associations

2014-02-11 Thread Marios Skounakis
I'm not sure there is a very clean solution.

When switching to edit mode, you could set the User's Job to a new Job
instance if it is null. You don't have to reattach/reassign any form
components if you simply update the AbstractEntityModel's object. I.e. you
either do
model.getModelObject().setJob(new Job())
or you do model.setModelObject(user with non-null job)

You will of course have to revert the job property back to null before
saving if all its properties are empty.

I would implement a Job#isEmpty() method to help me decide if I need to set
user.job to null before saving to the db.

Note you may also have to delete an existing Job record if the user goes
ahead and updates it's name to null.

Marios



On Tue, Feb 11, 2014 at 4:22 PM, ChambreNoire a...@tentelemed.com wrote:

 I forgot to mention, the reason I don't systematically make a new Job
 instance is that when saving the form hibernate creates a new Job instance
 which is effectively empty if no Job details have been input.

 Chambre

 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/Submitting-values-for-null-associations-tp4664365p4664369.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org