• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to use WODisplayGroup
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use WODisplayGroup


  • Subject: Re: How to use WODisplayGroup
  • From: Johann Werner <email@hidden>
  • Date: Sun, 7 Dec 2008 16:05:15 +0100


Am 07.12.2008 um 15:44 schrieb Francesco Romano:


On 07/dic/08, at 15:24, Johann Werner wrote:

Hi Francesco,

Am 07.12.2008 um 14:54 schrieb Francesco Romano:

I can't modify it..

This is the code: (inside a form)

<wo:form>
<fieldset>
<wo:if condition = "$isTableLuogo">

<wo:loop list = "$ipnDisplayGroup.displayedObjects" item = "$aLuogo">
<p><wo:textfield value = "$aLuogo.nome"></wo:textfield></p>
</wo:loop>

</wo:if>
<p><wo:link action="$addItem"> aggiungiElemento</wo:link></p>
<p> <wo:link action = "$applyChanges">Applica</wo:link>
<wo:link action = "$cancelChanges">Annulla</wo:link>
<wo:link action = "$saveChanges">Salva</wo:link></p>
</fieldset>
</wo:form>


If I try to edit the field, and press "Apply" the record is not updated...
What is wrong?


(This is the code for applyChanges)

	public WOActionResults applyChanges() {
		session().defaultEditingContext().saveChanges();
		return null;
	}


First let me note that using the defaultEditingContext for modifying and saving objects is A Bad Thing™. Looking at your page code it should work but... the problems that could cause your page not function as you expect are:

1. when you submit the changes is it possible that your condition isTableLuogo changes during the takeValuesFromRequest phase?

2. what is the editingContext of your ipnDisplayGroup? If it is not using the default editing context of course you wont do anything by calling saveChanges on the defaultEditingContext.

Another little tip you should return context().page() instead of null. What is the difference of your applyChanges() and saveChanges()?

jw


I'm learning webobject while coding.. So I can do errors and do something "very ugly" that (temporary) work.. I'm happy to be corrected! (it was the same with Cocoa when I started :) )

I think thats the way almost any here on the list got WO coding right ;-)


So...
The easiest answer:
The difference between Apply and save is that apply commit the changes, and save commit changes and change page.


Than... why I use that condition...
Maybe I'm making a "very bad Thing"... There are a lot of WOComponent... so.. I created a generic WOComponent to show the tables... and with the if I check which table should I show... is this a bad thing? (I think yes...)

If I got your idea right you should look at WOSwitchComponent. The problem I mentioned in the last e-mail is if your condition evaluates to true (showing your rows) and then you are submitting changes where during the takeValues phase the condition changes to false the new values are not set as WO thinks that those objects are not on that page. This is one of those pitfalls of WO where the whole request- response-loop can puzzle quite easily.



This is the code when I created the WODisplayGroup:

EODatabaseDataSource ds = new EODatabaseDataSource(session().defaultEditingContext(),_table);
ipnDisplayGroup.setDataSource(ds);
ipnDisplayGroup.fetch();


And... if using defaultEditingContext is a bad thing.. what should I use??

You should create your own local editing context that is bound to that specific page. This gives you the certainty that no actions on other pages can changes your data. Of course you have to pay attention to locking/unlocking your editing context as only for the default editing context this is done automatically. You should consider using Wonder right from the beginning as it gives you a plethora of out-of-the-box features as autolocking.


jw


Francesco
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How to use WODisplayGroup
      • From: Francesco Romano <email@hidden>
References: 
 >How to use WODisplayGroup (From: Francesco Romano <email@hidden>)
 >Re: How to use WODisplayGroup (From: Johann Werner <email@hidden>)
 >Re: How to use WODisplayGroup (From: Francesco Romano <email@hidden>)
 >Re: How to use WODisplayGroup (From: Ramsey Lee Gurley <email@hidden>)
 >Re: How to use WODisplayGroup (From: Francesco Romano <email@hidden>)
 >Re: How to use WODisplayGroup (From: Johann Werner <email@hidden>)
 >Re: How to use WODisplayGroup (From: Francesco Romano <email@hidden>)

  • Prev by Date: Re: How to use WODisplayGroup
  • Next by Date: Re: How to use WODisplayGroup
  • Previous by thread: Re: How to use WODisplayGroup
  • Next by thread: Re: How to use WODisplayGroup
  • Index(es):
    • Date
    • Thread