Why bind doesn' work?

Hi, please help me to understand why bind doesn't work.
Here is my code:
/** Simple enum used in bean. */
public enum CommandType {
    NOP, CREATE, UPDATE, DELETE, MOVE;
/** just simple bean. */
public class Command {
    private CommandType commandType;
    private Integer objectId;
    /** Getters and setters are here*/
    @Override
    public String toString(){
        return "Command{commandType=>"+commandType.name()+",objectId=>"+objectId+"}";
* Enum for singleton pattern realization.
* The idea: currentCommand is changed in single threaded environment. JavaFX is binded on this filed.
public enum CommandPublisher {
    PUBLISHER;
    /** For generating random Integers. */
    private Random random = new Random();
    /** Trying to bind JavaFX on this field value. */
    public Command currentCommand = new Command(CommandType.NOP, -1);
    /** Getter... */
    public Command currentCommand(){
        return currentCommand;
    /** Set new value. */
    public void setCommand(Command newCommand){
        currentCommand = newCommand;
    /** Utility method. Just set new command to currentCommand. */
    public Command generateRandomCommand(){
        return new Command(CommandType.CREATE, random.nextInt());
    public void setNewRandomObjectId(){
        currentCommand.setObjectId(random.nextInt());
/** JavaFX code*/
/** on replace works only one: when CommandPublisher is initialized, javaFXcurrentCommand  gets new value,
*   was: null, became: Command{commandType=>NOP,objectId=>-1}
var javaFXcurrentCommand = bind CommandPublisher.PUBLISHER.currentCommand on replace oldValue{
   println("Bind? oldValue={oldValue}, newValue={javaFXcurrentCommand}");
Stage {
    title: "JavaFX bind on Java object field. "
    scene: Scene {
        width: 250
        height: 80
        content: [
            Text {
                font : Font {
                    size : 16
                x: 10
                y: 30
                content: "Application content"
            Button {
                 text: "Change currentCommand through CommandPublisher"
                onMouseClicked:
                function(e: MouseEvent) {
                    println("Mouse clicked -> Change currentCommand through CommandPublisher");
                    /** JavaFX var realy gets new objectId though java object field. But "on replace"  doesn't work. */
                    //CommandPublisher.PUBLISHER.setNewRandomObjectId();
                    /** Tried to use these methods: nothing happens. */
                    //CommandPublisher.PUBLISHER.currentCommand = CommandPublisher.PUBLISHER.generateRandomCommand();
                    //CommandPublisher.PUBLISHER.setCommand(CommandPublisher.PUBLISHER.generateRandomCommand());
                    println("currentCommand -> {javaFXcurrentCommand}");
                    println("Mouse clicked ##");
}Sample output:
init:
deps-jar:
compile:
jar:
standard-run:
Bind? oldValue=null, newValue=Command{commandType=>NOP,objectId=>-1}
Mouse clicked -> Change currentCommand through CommandPublisher
currentCommand -> Command{commandType=>NOP,objectId=>-1}
javaFXcommand -> Command{commandType=>NOP,objectId=>-1}
Mouse clicked ##
Mouse clicked -> Change currentCommand through CommandPublisher
currentCommand -> Command{commandType=>NOP,objectId=>-1}
javaFXcommand -> Command{commandType=>NOP,objectId=>-1}
Mouse clicked ##
As you can see, "on replace" is fired only once: when Enum became initialized.
mouse clicking doesn't force "on replace" to work.
What do I do wrong?

Hi, please help me to understand why bind doesn't work.
Here is my code:
/** Simple enum used in bean. */
public enum CommandType {
    NOP, CREATE, UPDATE, DELETE, MOVE;
/** just simple bean. */
public class Command {
    private CommandType commandType;
    private Integer objectId;
    /** Getters and setters are here*/
    @Override
    public String toString(){
        return "Command{commandType=>"+commandType.name()+",objectId=>"+objectId+"}";
* Enum for singleton pattern realization.
* The idea: currentCommand is changed in single threaded environment. JavaFX is binded on this filed.
public enum CommandPublisher {
    PUBLISHER;
    /** For generating random Integers. */
    private Random random = new Random();
    /** Trying to bind JavaFX on this field value. */
    public Command currentCommand = new Command(CommandType.NOP, -1);
    /** Getter... */
    public Command currentCommand(){
        return currentCommand;
    /** Set new value. */
    public void setCommand(Command newCommand){
        currentCommand = newCommand;
    /** Utility method. Just set new command to currentCommand. */
    public Command generateRandomCommand(){
        return new Command(CommandType.CREATE, random.nextInt());
    public void setNewRandomObjectId(){
        currentCommand.setObjectId(random.nextInt());
/** JavaFX code*/
/** on replace works only one: when CommandPublisher is initialized, javaFXcurrentCommand  gets new value,
*   was: null, became: Command{commandType=>NOP,objectId=>-1}
var javaFXcurrentCommand = bind CommandPublisher.PUBLISHER.currentCommand on replace oldValue{
   println("Bind? oldValue={oldValue}, newValue={javaFXcurrentCommand}");
Stage {
    title: "JavaFX bind on Java object field. "
    scene: Scene {
        width: 250
        height: 80
        content: [
            Text {
                font : Font {
                    size : 16
                x: 10
                y: 30
                content: "Application content"
            Button {
                 text: "Change currentCommand through CommandPublisher"
                onMouseClicked:
                function(e: MouseEvent) {
                    println("Mouse clicked -> Change currentCommand through CommandPublisher");
                    /** JavaFX var realy gets new objectId though java object field. But "on replace"  doesn't work. */
                    //CommandPublisher.PUBLISHER.setNewRandomObjectId();
                    /** Tried to use these methods: nothing happens. */
                    //CommandPublisher.PUBLISHER.currentCommand = CommandPublisher.PUBLISHER.generateRandomCommand();
                    //CommandPublisher.PUBLISHER.setCommand(CommandPublisher.PUBLISHER.generateRandomCommand());
                    println("currentCommand -> {javaFXcurrentCommand}");
                    println("Mouse clicked ##");
}Sample output:
init:
deps-jar:
compile:
jar:
standard-run:
Bind? oldValue=null, newValue=Command{commandType=>NOP,objectId=>-1}
Mouse clicked -> Change currentCommand through CommandPublisher
currentCommand -> Command{commandType=>NOP,objectId=>-1}
javaFXcommand -> Command{commandType=>NOP,objectId=>-1}
Mouse clicked ##
Mouse clicked -> Change currentCommand through CommandPublisher
currentCommand -> Command{commandType=>NOP,objectId=>-1}
javaFXcommand -> Command{commandType=>NOP,objectId=>-1}
Mouse clicked ##
As you can see, "on replace" is fired only once: when Enum became initialized.
mouse clicking doesn't force "on replace" to work.
What do I do wrong?

Similar Messages

  • One reason why commandLink doesn't work in dataTable

    Ok, so I think I've got an explanation why commandLink doesn't work in dataTable when the model bean is request scoped. Maybe somebody can tell me if I'm wrong.
    I have a model bean that generates table rows based on some input criteria (request parameters).
    So, we validate the inputs, apply them to the bean and render the page. Once the inputs have been applied to the bean, a request for table rows returns rows, no problem.
    However, we put a commandLink in each row, so we can expand the details. Maybe we even get smart and repeat the input row-generating criteria as a hidden field in the page.
    Unfortunately, when the user hits the commandLink, the list page simply refreshes, maybe even w/out table rows. The user doesn't get the details page as expected.
    Why not?
    Because: in the DECODE phase (even before validation and before "immediate" values have had their valueChangeListeners called), we ask the model bean for the table rows, so we can decode the commandLinks. Unfortunately, in "decode" phase, the request-scoped model bean has not had its row-generating criteria updated (that happens in the "update model" normally, or at the END of the decode phase if we got cute by (1) setting the "immediate" attribute on the row-generating criteria to "true" AND (2) set a valueChangeListener to allow us to update the model bean early. The END of the decode phase isn't good enough -- in the middle of that phase, when we're attempting to deocde commandLinks, the model bean has no citeria, so there's no row data. No row data means no iteration over commandLinks to decode them and queue ActionEvents. So, we march through the rest of the phases, process no events, and return to the screen of origin (the list screen) with no errors.
    So, what's the solution?
    One solution is to make the model bean session-scoped. Fine, maybe we can store a tiny bit of data in it (the search criteria), so it's not such a memory drag to have it live in the session forever. How do we get that data in? A managed property in faces-config.xml with value #{param.PARENT_KEY} won't work because it's assigning request-scoped data to a session-scoped holder. JBoss balks, and rightly so. Do we write code in the model bean that pulls the request parameter out of thin air? (FacesContext.getExternalContext()....) I don't really like to code the name of a specific http request parameter into the bean, I think it's the job of the JSP or faces-config.xml to achieve that binding (request parameter to model propery). Plus, I'd be sad to introduce a dependency on Faces in what was previously just a bean.
    Is there a better way?
    In my particular situation, we're grafting some Faces pages onto an already-existing non-Faces application. I don't get the luxury of presenting the user an input field and binding it to a bean. All I've got to work with is a request parameter.
    Hmm, I guess I just answered my own question. if all I've got to work with is a request parameter, some ugliness is inevitable, I guess.
    I guess the best fix is to cheat and have the bean constructor look for a request parameter. If it finds it, it initializes the criteria field (which, in my case, is the key of an object that has a bunch of associated objects (the rows data), but could be more-general d/b search criteria).
    (I looked at the "repeater" example code in the RI, but it basically statically-generates its data and then uses 100% Faces (of course) to manage the paging (where "page number" is essentially the "criteria").
    Comments? Did I miss something obvious?
    John.

    ...or I could just break down and do the thing I was hoping to avoid (outputLink instead of commandLink):
    <h:outputLink value="/faces/Detail.jsp">
      <f:param name="PARENT_KEY" value="#{bean.parentKey}"/>
      <h:outputText value="#{bean.label}"/>
    </h:outputLink>It's still a "hardcoded" parameter name, but at least the binding is in the JSP and faces-config.xml, not the bean Java code.

  • I hate the new operating system. Can't connect to wifi in home anymore even after a restore. Rhapsody no longer works on my phone either. Plus the brighth graphics are bothering my eyes even with brightness turned down. Any ideas on why rhapsody doesn't w

    I hate the new operating system. Can't connect to wifi in home anymore even after a restore. Rhapsody no longer works on my phone either. Plus the brighth graphics are bothering my eyes even with brightness turned down. Any ideas on why rhapsody doesn't why rhapsody doesn't work anymore?

    Contact Rhapsody to see if they have or plan to release an update for the app. Try uninstalling and reinstalling the app. Have you tried resetting your device by pressing and holding the Home button and power button until the silver apple appears?

  • "why siri" doesn't seem to work unless we are charging the phone

    "why Siri" doesn't work unless we are charging our phones, why?

    I get that it's a safety issue and battery drain both, to not allow it unless plugged in but does that mean Google ("Ok Google") doesn't care about our safety?
    It's poor implementation I think. Battery drain isn't at all horrible on Android when it's always listening and I'm not starting that argument because i like iPhone and Apple just as well but it seems like there could have been other battery saving things to disable other than one that's very handy regardless of having to be plugged in.
    2cents

  • Confused as to why this doesn't work...

    I wrote this code correctly, but it doesn't seem to work. I'm not sure if I'm leaving something out or not using something correctly. If anyone can tell me why this doesn't work, it would be greatly appreciated!
    P.S. in the actionPerformed method, I want to put the window to close once someone clicks an "ok" button. How is this done? I've tried using setDefaultCloseOperation(3), but it doesn't seem to work.
    peace,
    Mark
    //?2002 Copyright. MJA Technologies.  All Rights Reserved.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class About extends JFrame implements ActionListener
        JTextArea textarea;
        JPanel panel1;
        JButton okbutton;
        String output;
        public About()
            super("Pages");
            Container container = getContentPane();
            textarea = new JTextArea();
            textarea.setText("Pages 1.0 beta 0\n?2002 MJA Technologies.\nAll Rights Reserved.");
            container.add(textarea);
            setDefaultCloseOperation( 3);
            setVisible(true);
            setSize(400, 300);
        public void actionPerformed(ActionEvent event)
            if(event.getSource() == okbutton)

    Oh see, you said this:
    "P.S. in the actionPerformed method, I want to put the window to close once someone clicks an "ok" button. How is this done? I've tried using setDefaultCloseOperation(3), but it doesn't seem to work."
    so I said this:
    "setVisible(false)"
    NOOOOOOOOOOOW you say the TextArea doesn't show up...that's a whole other problem.
    Jeeeeeeeeeeeeeeeez.
    So what layout manager are you using in the container? (hint hint)

  • Genius only works on some songs?  WHy - there doesn't seem to be any rhyme or reason.  Decemberists yes, Lana del Rey no.  Ideas?

    Genius only works on some songs?  WHy - there doesn't seem to be any rhyme or reason.  Decemberists yes, Lana del Rey no.  Ideas?

    Is there a batch process that runs in the evening? Perhaps that ends up cleaning out the data from the buffer cache, turning logical I/O's into physical I/O's early in the morning.
    Can you check the statistics on the table before the process starts and after you re-gather statistics? Perhaps there is a nightly process that is altering the statistics at an unfortunate time or in an unfortunate way.
    The previous poster's comment about getting a trace file is excellent as well-- whatever your session is waiting on will be apparent in the trace.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Why FaceTime doesn't work in Saudi Arabia ?

    why FaceTime doesn't work in Saudi Arabia ?

    we have stores sell apple products some of them sell with faetime at a high rate,
    and some other sell apple products without facetime at a normal price.
    finaly we need apple stores in Saudi Arabia to prevent this fraud.
    thank you
    what you're saying here is that some people parallel import apple products around the normal channels and they are from other countries so they havent got facetime blocked
    and others normally import apple products and they are blocked
    and then you go on believing that if apple had a store in saudi things would be better rest asured that if they did they would sell products with facetime blocked

  • Why Zinio doesn't show all issues on iPhone 4 but works correctly on ipad?

    Why Zinio doesn't show all issues on iPhone 4 but works correctly on ipad?
    The same issue is not present on iPhone 4 but exists on iPad
    Can anyone help?

    Try http://www.lemkesoft.com/ GraphicConverter.

  • Protocol binding doesn't work for OVPN clients.

    As title, it seems protocol binding doesn't apply to users remote connecting via OVPN, meaning that even though I have a rule covering 172.0.0.1 - 172.0.0.254 for all traffic to wan2 the remote users outgoing traffic is still getting loadbalanced.
    This causes a problem for SSL sites as it's not hitting the rules to pin to wan2.

    I will have to verify this since the LRT OpenVPN Server shouldn't be using outgoing Load Balancing and get back to you.
    Please remember to Kudo those that help you.
    Linksys
    Communities Technical Support

  • Binding not working when returning to same page

    Hi, Im developing a portlet that access some data from MYSQL.
    I have a simple page with several textfields, all with bindings to a javabean object that is a property of SessionBean1 bean, so it is a Session Scope bean.
    In that page I put some buttons like next, prior, etc. to navigate between all registers of my DB. I added some code to event button like this:
    public String bnext_action() {
    // get sessionbean
    SessionBean1 SBean1 = (SessionBean1)getBean("SessionBean1");
    // navigate to next register in database
    // ProdBean is my property bean that get values from database
    // bindings are like this : text="#{SessionBean1.prodBean.codigo}
    SBean1.getProdBean().GetNextReg(SBean1.getModuloIdx());
    // set current register index
    SBean1.setModuloIdx(SBean1.getProdBean().getIndex());
    return null;
    The problem is that when I get next register of database, bindings are not reflecting new values, always holding first values. I tried to force things by setting values in pre-rendering face manually with setText method of textfields but nothing happens.
    As Im a newbie in Java yet I really don't undestand this, I have readed all JSF life cycle documention and portlet life cycle docs but couldn't find an answer. Why binding is not working?

    Thanks for this.  Unfortunately now I have tried with Standard actions the links do not work at all.  The links provided were created with spaces so contained within the links are lots of '%20'. e.g. :
    PCI%20DSS/UWE%20PCI-DSS%20Quick%20Reference%20guide.pdf
    for some reason when creating the links with standard actions, when the project is published the links have changed to contain 25s  e.g.
    PCI%2520DSS/UWE%2520PCI-DSS%2520Quick%2520Reference%2520guide.pdf
    no idea why this is happening.

  • Why Aperture doesn't send the RAW file to Photoshop

    I've seen the complaint about Aperture not passing the original RAW file to Photoshop in several places in this forum. I think I have a reason for why Aperture doesn't work this way.
    The reason has to do with the 1st law of digital RAW photography. "Never, ever, overwrite the original RAW data from a camera's RAW format file."
    Because of the above rule, both Aperture and Photoshop do not actually work on the original RAW file. They transform the RAW image data into a usable image using user specified settings (which may be the camera's default setting for that image). The original RAW file is left untouched.
    When you open a RAW file in Photoshop and try to save it, you'll be prompted for a new file name. You wouldn't want to overwrite the original RAW file by writing the edited image data back to it.
    When you edit an Aperture RAW file using Photoshop as the external editor, Aperture first creates a TIFF or PSD version image file in its library and then passes that file name to Photoshop. Photoshop opens the TIFF or PSD file and directly edits it. Since this version file is already in Aperture's library, when Photoshop is finished editing it, Aperture automatically sees the edited file because its already in the library.
    If Aperture were to send the RAW file name to Photoshop, Photoshop would open the RAW file and create a new PSD file. When it came time to save your edits, where would you save it. In order to get it back into Aperture's library, you would need some form of Photoshop to Aperture communication so that Photoshop would know where to save the edited file and Aperture would know to add it to the library. This would require collaboration between both Adobe and Apple and doesn't seem likely.
    I have a couple of ideas someone can try. These are only ideas and completely untested. I'd do it myself but I don't own Aperture (see my computer info below for the reason).
    1. Create two folders with automator actions. You export your RAW files from Aperture to a "Photoshop-IN" folder. Any new RAW image found in this folder will be automatically opened in Photoshop by the Automator action. Then you save the edited Photoshop file into a 2nd folder "Aperture-IN". Another Automator action imports this into Aperture.
    2. In iPhoto, if you try to edit a RAW image with an external editor, iPhoto creates an intermediate image file (JPEG I think) which it passes to Photoshop. But, if you drag the original RAW image thumbnail from iPhotos library window to the Photoshop icon in the dock, the original RAW image file is passed to Photoshop. You only have the problem of getting the saved Photoshop file back into iPhoto's library. Maybe this same thing would work in Aperture by dragging the Master image to the Photoshop icon in the dock.
    PowerMac G4 Dual 1.25GHz   Mac OS X (10.4.3)   FW800, 4 internal HD - 550GB

    This is all well and good. I wholeheartedly agree with the idea of keeping the "master" sacrosanct. What I object to is not being able to do the conversion in Photoshop (or elsewhere)
    What I want is for Aperture to send the raw over to photoshop when I select "open in external editor", and then follow the current workflow (I do my edits, hit save, and a second master is added to Aperture's db.)
    It's totally possible for them to do this, and it wouldn't break anything in the system, or the philosophy. Of course it's a workaround that wouldn't be necessary if Aperture's converter were up to snuff. But it isn't, and I bet it would be easier to implement the workaround than to fix the fundamental defects in the converter itself.

  • Why iphone doesn't tell me when i call someone having an active call that i am on waiting?

    why iphone doesn't tell when i call someone having an active call that i am on waiting?

    hey i had the same problem, look and i fixed it just slightly tighten the 2 screws on the bottom of the phone with the tip of the knife or a small screw driver!! and now my phone works perfectly
    guys it really worked trust me

  • Why Arabic doesn't show up properly in Safari?

    Why Safari doesn't render arabic fonts properly while Firefox and Opera do?
    They renders diacritic signs correctly while Safari messes up. In ذَهَبَ، -َ، يَذهَبُ the last Damma in Safari appears at the beginning of the words. The HTML code is the same but Safari makes mistakes, why?
    I published a little dictionary (http://homepage.mac.com/pvmantel/arabo/home.html) but it cannot be properly seen in Safari (IE doesn't even show the arabic letters!!).
    Thanks for any suggestion to make Safari working properly
    Paolo
    Powerbook G3   Mac OS X (10.4.3)  

    Tom, I see you are an expert on the topic and I hope you, or anyone knowledgable, can help me out. as per the popular suggestion of getting rid of all things "arial" and "times new roman" to fix the safari mess-up, I actually removed every instance of these fonts (with all their possible variations, bold, italic, etc) from all locations, not just the user/lib/fonts location, but to no avail... while my Safari can properly read "some" arabic websites, it scrambles arabic up on most others, Two popular examples would be aljazeera.net and www.alarabiya.net. any help or suggestion would be greatly appreciated.....

  • Why Quicktime doesn't recognize my camcorder HVR-A1 on a smaller Macbook but does on the 17" one?

    Why Quicktime doesn't recognize my camcorder HVR-A1 on a smaller Macbook but does on the 17" one using 400 Firewire adapted to 800?

    I'm baffled why the mic works fine with Dictation but not with QuickTime.
    QT likely uses core routines which are compatible with your Lion OS and what can be seen in the "System Preferences" window. On the other hand, Dictation may be using an alternative workflow which can still see/use your mic. To add to the confusion, it appears Lion included changed audio handling routines which, according to some, were released before proper test had been completed and finalized with the release of Mountain Lion. (I.e., Snapz Pro X and WireTap from Ambrosia are still scrambling to update their system audio capture software for these changes but ScreenFlow's routines seem to work already.) In any case, I suspect your problem may be related to the Lion/Mountain Lion audio handling modifications but have no way to confirm such at this time.

  • Any body know why FCPX doesn't support footage recorded in 1080-60P form Panasonic HDC-TM900 camcorder?, Any body know why FCPX doesn't support footage recorded in 1080-60P form Panasonic HDC-TM900 camcorder?

    Anybody know why FCPX  doesn't support footage recorded in 1080-60p form Panasonic Camcorder HDC-TM900???

    I'm trying to decide on a new camcorder between the new yet to be released Panasonic HD-X900M and the Canon VIXIA HF G10.  Currently have a Canon HV 20 which works great, but thought I'd upgrade to newer tech.  Looking at the supported cameras list published by Apple, the newer Panasonic hasn't been tested yet so am unsure if it is the same as the previous model.  I suspect it is.  The newer Canon appears to be good, but spec. say it is only good up to 1080I.  I'd rather have the progressive camera if it isn't that much of a hassle to convert the files.
    Thanks for alll your info on this subject. 
    Dale

Maybe you are looking for

  • Macbook Pro mid 2012 15" Freezing Inconsistently

    I've had quite an ordeal with my Macbook Pro over the last few years, so this will be a lengthy question, sorry in advance. Let me get right to it. Backstory: I bought my MBP 15" new in summer of 2012. I had 8GB of laptop ram that had been in my moth

  • Setup problem with acquired ipad

    When setting up a 16gb ipad I acquired from a former employee, I use my apple ID the same as for my iphone but it doesn't accept it and when selecting the "forgot password" option, I get the message Cannot Load iForgot. I'm stuck in setup right now.

  • Creation of inbound shipments with reference to GR

    Hi Gurus, Is it possible to create a shipment document with reference to GR made from the PO's? I understand that there is a procedure to create inbound shipment from inbound deliveries. I would like to know if inbound delivery is mandatory to create

  • My iPad is stuck in recovery mode.  I already downloaded Snow Leopard and am making no progress.  Help!

    My iPad is stuck in recovery mode.  It was suggested before that I upgrade my computer, so I downloaded Snow Leopard and have tried resetting it, but it still isn't working.  What can I try next?

  • Check box in Tree ui element.

    Hi All I am using org.eclipse.swt.widgets.TreeItem for creating tree structure. Now I am trying to incorporate check box for last tree element. For example if I am preparing tree structure for files the check box should appear only for text file not