MVC: update only one time

Hi,
suppose I've this model class:
public class MyClass extends java.util.Observable {
     public MyClass(){}
     //get methods
     //set methods
     private int x;
     private int y;
     private int z;
     private int t;
     private int s;
}Now I want that, when I use more than one set method, observers are notified only one time.
That is,
if I have this calls:
MyClass obj = new MyClass();
obj.setX(1);
obj.setY(2);
obj.setZ(3);
obj.setT(4);
obj.setS(5);I want that the update method isn't called five times, but only one time.
I can't add setChanged() and NotifyObservers() in only one of the set method,
because I 'm interesting in knowing when the model has been modified.
I thought of adding a new set method like this:
setModified(){
   setChanged();
   notifyObservers();
}so, every time I want to notify observers, I run this method.
But, I want to know:
Is this the correct way to do?
Thank you in advance.
MargNat

No,
the five values doesn't always change all at once.
I can have this code in one class:
obj.setX(45);
obj.setY(46);and in another class this:
obj.setX(45);
obj.setZ(345);
obj.setT(345);I simply don't want the observers are called many times.
the values are indipendent among them, I don't want to have only one set method for them;
this isn't an object oriented approach.
Practically, I want to know where exactly must be placed setChanged() and notifyObservers() methods.
In all model methods?
In a specific method I can call every time I want to update?
I must call setChanged() and notifyObserver() directly, as example, like:
obj.setChanged()
obj.notifyObservers?
Thank you again.
MargNat

Similar Messages

  • HT204053 i am having iphone3gs and ipod4s, is it possible the application that i have purchased in my iphone can be available in my i pod by doing payment only one time for the same application in my i phone...if yes,plz let me know hw it is possible

    i am having iphone3gs and ipod4s, is it possible the application that i have purchased in my iphone can be available in my i pod by doing payment only one time for the same application in my i phone...if yes,plz let me know hw it is possible..

    Open the App Store on your device.
    Make sure you are signed in with the same account used for the original purchase.
    Tap on Purchased from the bottom navigation bar.
    On iPhone or iPod touch, tap Updates from the bottom navigation bar, then tap Purchased.
    Locate the app in your Purchased tab.
    Tap the download button (cloud symbol)
    See also: http://support.apple.com/kb/HT2519?viewlocale=en_US&locale=en_US

  • Access for update only one column in table?

    Hi all,
    My need is to grant access for update only one column c1 in table t1.
    I guess I should use view, could you please give me some example? Maybe other ideas?

    Hi,
    You can grant privileges on individual columns.
    GRANT   UPDATE (c1)
    ON      t1
    TO      grantee_name;Look up GRANT in the SQL language manual. Annoyingly, in recent editions of the manual, GRANT is not indexed, but it's in alphabetic order with all the other statements:
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_9013.htm#i2155015

  • Pricing: condition type PR00 only one time enter

    Dear
    In sale order we have condition type PR00 and it is manualy condition type , now user was entering the same condition type(PR00)
    Two times ,how can we  restrict that PR00 is enter only one time in  the sale order

    Check this thread where the same topic was dicussed.
    [how tostop duplicate conditype entry in to prcing at order |Re: how tostop duplicate conditype entry in to prcing at order processing lev;
    thanks
    G. Lakshmipathi

  • BMP EJB Load and Store is calling only one time calling in a loop

    Loop Iterating two times but ejb load and store is calling only one time.
    Application deployed in 0c4j 10.1.2.0.0 container.

    This sounds more like a Teststand quesstion. You might want to post it there.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Structure inside while should work only one time ?

    Hi Everyone ,
                      I have coded a program that if i click a button ( switch untill released) . inside that structure should work only one times . 
                      and i have coded and its working fine .. but its looks compilcated..
                       i need some simple solution . Plz help me guys 
    Attachments:
    CODE.vi ‏10 KB

    saran1988 wrote:
                      I have coded a program that if i click a button ( switch untill released) . inside that structure should work only one times . 
                      and i have coded and its working fine .. but its looks compilcated..
                       i need some simple solution . Plz help me guys 
    Your code has very little to do with what you are describing.
    There is no button with "switch until released" mechanical action. (OK is switch when released, stop is latch when released)
    A case structure always "works". Are you saying that it should execute e.g. the true case only once whenever the outer case goes from false to true??
    Your inner case goes true more than once per run of the program (whenever the OK goes true). If it should really only work once overall, use the "first call?" primitive. You need to formulate the problem using less ambiguous words.
    There is no obvious starting state for the boolean that you read via local variables. How do you ensure that it start with a known value? Does it matter?
    You seem to entirely deal with integers, so why are you using floating point representation for the numerics?
    What is the purpose of the orange numeric indicator. Is it just a kludge for your logic or does its value mean anything?
    Why does your loop not contain any wait?
    At this point, you should learn about shift registers. It would eliminate all your local variables.
    LabVIEW Champion . Do more with less code and in less time .

  • Repeated Region: show dubble entries only one time

    I want to make a recordset where all 'cities' are shown only one time, It should not be like
    The Hague
    The Hague
    The Hague
    Rotterdam
    Rotterdam
    Amsterdam
    But:
    The Hague
    Rotterdam
    Amsterdam
    This is the recordset:
    SELECT c_city FROM canteen
    This is the repeated region:
    <?php do { ?><?php echo $row_allCities['c_city']; ?><?php } while ($row_allCities = mysql_fetch_assoc($allCities)); ?>
    Thankx for any further help!

    Add a DISTINCT statement to your query.
    SELECT DISTINCT  c_city FROM canteen
    Lawrence   *Adobe Community Expert*
    www.Cartweaver.com
    Complete Shopping Cart Application for
    Dreamweaver, available in ASP, PHP and CF
    www.twitter.com/LawrenceCramer

  • Custom Ringtones ring only one time ( Please Report to Xperia Z2 Developers )

    I buy Z2 last weak, before it i was using Z1.
    Both devices have one error in their Firmware and that is about ringtone.
    no matter whatever the custom ringtone you set for ringtone notification its ring only one time and then only vibrate.
    For example i set a tone which is 12 second tone so when ever some one call me after 12 second the ringtone did not repeat.
    Sample video
    https://www.youtube.com/watch?v=IDy2...ature=youtu.be

    Try a software repair:
    http://www.sonymobile.com/gb/tools/pc-companion/
    All we have to decide is what to do with the time that is given to us - J.R.R. Tolkien

  • Refresh the window only one time

    hi,
    i want to refresh my window only one time using the javascript code window.location = window.location.href. But i am in a situation to write the code in the event of form load. so i the code is executing infinitely. but i want to refresh my window for only one time. any suggestion would be appreciated. thanking u
    rgds
    parameswaran

    Send a URL param with it, then check for that param before refreshing.
    And this isn't really JSP-related.

  • Value only one time displayed

    Hello all,
    one question: I have a report region. In one column a value is several times among each other. What can I do, the same values display only one time?
    Thanks a lot!
    Regards
    Daniel

    Daniel,
    Not sure if I have exactly understood your question but are you talking about Break Formatting? So that a report will display like:
    CATEGORY | PRODUCT
    Computer - Monitor
    - Keyboard
    - Mouse
    Car - Wheel
    - Engine
    - Gears
    instead of:
    Computer - Monitor
    Computer - Keyboard
    Computer - Mouse
    Car - Wheel
    Car - Engine
    Car - Gears
    If so, you'll want to investigate Break Formatting in your Report Attributes or look in the Help for more details on this.
    Sorry if that's not what you meant...
    Andy

  • Only one time Froforma Invoice

    Hi All,
    Is there is any check for Froforma Invoice that should come only one time ...when they will creat the forforma invoice the system should give a error massage that " the Proforma Invoice is already created" and that is error massage ...
    Thanks in advance ....
    Regards,
    Abhijit

    Hi Samier,
    Actually the requirement is they will allow the user to take only one time Proforma invoice ...But in SAP standard u can take save the Froforma invoice as many times as the user want ...In item category the completion rule will not work ....because i want to check the delivery document should be refence for two times once for F2 and again for F8.As if we want to creat the billing doc for 2 time the system shows this billing has already been done ...that is also applicable for F8....
    Regards,
    Abhijit......................

  • If I want to purchase PhotoShop CS6 for my company, how many computers can install this copyright or only one time of installation?

    If I want to purchase PhotoShop CS6 for my company, how many computers can install this copyright or only one time of installation?

    YOu can install and activate on 2 computers for non-concurrent use.
    Mylenium

  • LSMW to update only one field in materials

    Hello experts,
    My requirement is to update only one field 'HRKFT-Origin Group as Subdivision of Cost Element' in material using LSMW. I tried with Standard Batch/Direct Input -> Object - 0020, Method - 0000. But it was not successful as it gave me warning - 'The material cannot be maintained since no maintainable data transferred' at the end.
    Now I want to try this using BAPI method in LSMW. But it is showing me error - No target structures could be determined..
    Please guide me.
    Regards,
    Aparna Gaikwad

    Hi
    i tried the same and am able to do it using LSMW Batch i/p.  Object - 0020, Method - 0000.
    There in source fields define material, plant and origin grp. in structure relations map the below
    BGR00 Batch Input Structure for Session Data                       <<<< MBEW1 Material COsting
          Select Target Structure BGR00 .
        BMM00 Material Master: Transaction Data for Batch Input            <<<< MBEW1 Material COsting
              Select Target Structure BMM00 .
            BMMH1 Material Master: Transfer of Main Data                       <<<< MBEW1 Material COsting
    Next in field mapping map those 3 fields: material, plant and origin grp.
    while testing do one thing. first take the data and try the same using MM02 manually. if tht is working fine ( i mean if the material is having costing view and you are able to chnage the origin group). then test with the same material, plant and a different origin grp. It will work.

  • Grant to update only one row

    Hi all,
    I'm working with an 10.2.0.3 Oracle Enterprise version.
    I need to create a new user on my database with permission to update only one row on table.
    Have you notice if this is possible? In case, how is the grant to do this?
    Regards,
    dbajug

    Try this:
    SQL> create user usr1 identified by usr1;
    User created.
    SQL> create user usr2 identified by usr2;
    User created.
    SQL> grant connect, resource to usr1,usr2;
    Grant succeeded.
    SQL> conn usr1/usr1
    Connected.
    SQL> create table t (id number);
    Table created.
    SQL> insert into t values(1);
    1 row created.
    SQL> insert into t values(2);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> grant update on t to usr2;
    Grant succeeded.
    SQL> create or replace trigger trg_t
      2  before update on t
      3  for each row
      4  begin
      5  if :old.id>1 then
      6  raise_application_error(-22299,'You cant change the specific value ');
      7  end if;
      8  end;
      9  /
    Trigger created.
    SQL> update usr1.t set id=2 where id=1;
    1 row updated.
    SQL> update usr1.t set id=2 where id=2;
    update usr1.t set id=2 where id=2
    ERROR at line 1:
    ORA-21000: error number argument to raise_application_error of -22299 is out of
    range
    ORA-06512: at "USR1.TRG_T", line 3
    ORA-04088: error during execution of trigger 'USR1.TRG_T'
    SQL>

  • Condition type only one time

    Hi ,
    In pricing procedure there is a manual condition type.Now the user can do entry for this condition type more than one time for the line item.If i want to stop that by the user ,what should  i do . Only requirement in the pricing procedure, is the option or there is anything else in the standard SAP ..Please suggest .
    Thanks ,
    Abhijit.

    dear abhijit,
    I have faced same problem and for this a solution is to maintain purchase infor record.
    like you must be purchasing article from different vendors then you can maintain the different purchasing price for different vendor
    Purchasing info records determine the prices suggested in purchasing documents in two ways:
    The system,
    • 1st searches under POrg. Data 1 - Conditions:
    Conditions are included if they have been maintained for an info record manually or from a quotation (but can be changed manually afterwards)
    • 2nd searches under POrg. Data 2 – Last Purch Doc.:
    If an info record does not contain any conditions (under POrg. Data 1), the system reads the number of the last purchasing document in the info record and then suggests the price from this document.
    ‘Info Update’ indicator for Conditions (in PO, RFQ/Quotation, Contract) :
    • for PO – the update occurs in POrg Data 2 (last purch doc)
    • for RFQ/Quotation - the update occurs at POrg Data 1 – Conditions (can be changed manually afterwards) and POrg Data 2.
    • for Contract – the update occurs at POrg Data 1 - Conditions, IF at the time of the contract creation there is No info rec. Otherwise the info rec is updated with the last release order under POrg. Data 2.
    but please note that the final price will get calculated on one condiition only and not on others.
    regards,
    Vishal
    Edited by: Vishal Jajoo on Feb 19, 2008 2:16 PM

Maybe you are looking for