OnChangeAjaxBehavior() - problem with id

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

OnChangeAjaxBehavior() - problem with id

lucky
Hi Colleagues,
 
I have listView where in TextArea I have used onChangeAjaxBehavior.
In update() I set edited text to the object.
Finally in saveButton (this button is required) via savingMethod() I add changes to database and then refresh form.
The problem is that when text is edited in given row (item) at the ListView after refresh action the edited text is assigned to the last item at the list.
I know that probably I must use in any way id but I don’t know exactly how to do it.
Generally saying in my application I must have one saveButton that will be common for all items at the list.
This button is also used to save new added item via separate text field in the form. This works fine.  
Can you suggest please solution. This is very urgent for me.
Please also eventually suggest solution without OnChangeAjaxBehavior.
Below is my code.



Regards,
Rafal

 

……
saveButton.add(new AjaxFormComponentUpdatingBehavior("onclick"){
protected void onUpdate(AjaxRequestTarget target) {
object.savingMethod(st);  //Saving changes to database
target.addComponent(form);
}
form.add(saveButton);

…..

final ListView list = new ListView("stListing", ListTekst) {
@Override
protected void populateItem(final ListItem<StandardTekst> item) {
 
TextClass st = new TextClass();
st = item.getModelObject();
                                               
final TextArea  tekst  = new TextArea ("stTekst",new PropertyModel(st, "tekst"));
tekst.add(new OnChangeAjaxBehavior() {
  @Override
  protected void onUpdate(AjaxRequestTarget target) {
    String editedText = (String) tekst.getModelObject();
    st.setTekst(editedText);                    
        }
Reply | Threaded
Open this post in threaded view
|

Re: OnChangeAjaxBehavior() - problem with id

Romeo Sheshi
hi

you can try in this way setting item.getModelObject() as final
final StandardTekst st = item.getModelObject();
and in the sva button you have to save the ListTekst



final ListView list = new ListView("stListing", ListTekst) {
@Override
protected void populateItem(final ListItem<StandardTekst> item) {

TextClass st = new TextClass();

+++final StandardTekst st = item.getModelObject();
---st = item.getModelObject();

final TextArea  tekst  = new TextArea ("stTekst",new PropertyModel(st,
"tekst"));
tekst.add(new OnChangeAjaxBehavior() {
 @Override
 protected void onUpdate(AjaxRequestTarget target) {
   String editedText = (String) tekst.getModelObject();
    st.setTekst(editedText);
   }

2010/7/20 lucky <[hidden email]>

>
> Hi Colleagues,
>
> I have listView where in TextArea I have used onChangeAjaxBehavior.
> In update() I set edited text to the object.
> Finally in saveButton (this button is required) via savingMethod() I add
> changes to database and then refresh form.
> The problem is that when text is edited in given row (item) at the ListView
> after refresh action the edited text is assigned to the last item at the
> list.
> I know that probably I must use in any way id but I don’t know exactly how
> to do it.
> Generally saying in my application I must have one saveButton that will be
> common for all items at the list.
> This button is also used to save new added item via separate text field in
> the form. This works fine.
> Can you suggest please solution. This is very urgent for me.
> Please also eventually suggest solution without OnChangeAjaxBehavior.
> Below is my code.
>
>
>
> Regards,
> Rafal
>
>
>
> ……
> saveButton.add(new AjaxFormComponentUpdatingBehavior("onclick"){
> protected void onUpdate(AjaxRequestTarget target) {
> object.savingMethod(st);  //Saving changes to database
> target.addComponent(form);
> }
> form.add(saveButton);
>
> …..
>
> final ListView list = new ListView("stListing", ListTekst) {
> @Override
> protected void populateItem(final ListItem<StandardTekst> item) {
>
> TextClass st = new TextClass();
> st = item.getModelObject();
>
> final TextArea  tekst  = new TextArea ("stTekst",new PropertyModel(st,
> "tekst"));
> tekst.add(new OnChangeAjaxBehavior() {
>  @Override
>  protected void onUpdate(AjaxRequestTarget target) {
>    String editedText = (String) tekst.getModelObject();
>    st.setTekst(editedText);
>        }
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/OnChangeAjaxBehavior-problem-with-id-tp2296313p2296313.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: OnChangeAjaxBehavior() - problem with id

lucky

Saving whole list is sensible but unfortunately I can’t do it because the saving method accepts only as parameter the object of TextClass.

The method is created by my colleague in different part of project and I can’t change it.

 

Regards,

Rafal



2010/7/21 Romeo Sheshi [via Apache Wicket] <[hidden email]>
hi

you can try in this way setting item.getModelObject() as final
final StandardTekst st = item.getModelObject();
and in the sva button you have to save the ListTekst



final ListView list = new ListView("stListing", ListTekst) {
@Override
protected void populateItem(final ListItem<StandardTekst> item) {

TextClass st = new TextClass();

+++final StandardTekst st = item.getModelObject();
---st = item.getModelObject();

final TextArea  tekst  = new TextArea ("stTekst",new PropertyModel(st,
"tekst"));
tekst.add(new OnChangeAjaxBehavior() {
 @Override
 protected void onUpdate(AjaxRequestTarget target) {
   String editedText = (String) tekst.getModelObject();
    st.setTekst(editedText);
   }

2010/7/20 lucky <[hidden email]>

>
> Hi Colleagues,
>
> I have listView where in TextArea I have used onChangeAjaxBehavior.
> In update() I set edited text to the object.
> Finally in saveButton (this button is required) via savingMethod() I add
> changes to database and then refresh form.
> The problem is that when text is edited in given row (item) at the ListView
> after refresh action the edited text is assigned to the last item at the
> list.
> I know that probably I must use in any way id but I don’t know exactly how
> to do it.
> Generally saying in my application I must have one saveButton that will be
> common for all items at the list.
> This button is also used to save new added item via separate text field in
> the form. This works fine.
> Can you suggest please solution. This is very urgent for me.
> Please also eventually suggest solution without OnChangeAjaxBehavior.
> Below is my code.

>
>
>
> Regards,
> Rafal
>
>
>
> ……
> saveButton.add(new AjaxFormComponentUpdatingBehavior("onclick"){
> protected void onUpdate(AjaxRequestTarget target) {
> object.savingMethod(st);  //Saving changes to database
> target.addComponent(form);
> }
> form.add(saveButton);
>
> …..
>
> final ListView list = new ListView("stListing", ListTekst) {
> @Override
> protected void populateItem(final ListItem<StandardTekst> item) {
>
> TextClass st = new TextClass();
> st = item.getModelObject();
>
> final TextArea  tekst  = new TextArea ("stTekst",new PropertyModel(st,
> "tekst"));
> tekst.add(new OnChangeAjaxBehavior() {
>  @Override
>  protected void onUpdate(AjaxRequestTarget target) {
>    String editedText = (String) tekst.getModelObject();
>    st.setTekst(editedText);
>        }
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/OnChangeAjaxBehavior-problem-with-id-tp2296313p2296313.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



View message @ http://apache-wicket.1842946.n4.nabble.com/OnChangeAjaxBehavior-problem-with-id-tp2296313p2296663.html
To unsubscribe from OnChangeAjaxBehavior() - problem with id, click here.