• 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
Bug in WOTextField?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug in WOTextField?


  • Subject: Bug in WOTextField?
  • From: Timo Hoepfner <email@hidden>
  • Date: Fri, 22 Feb 2008 10:14:43 +0100

Hi,

I've stumbled across a behaviour of WOTextField (and possibly other WOInput subclasses) which looks like a bug to me:

When you have a textfield within a form, that appears as a result of the submission of that form (e.g. because it's in a conditional, whose condition becomes true as a result of the form submission), it will set it's binding to null during takeValuesFromRequest, as it's name doesn't appear in the WORequest's formValueKeys, which is (mis-)interpreded as "value is null". IMHO, the WOTextField should only set the binding, if it's name appears in the formValueKeys.
Is this a bug or intended behaviour?
I'm not sure, why this doesn't happen, when e.g. using a WOCollapsibleComponentContent with submitActionName bound. Probably I have to re-read "The secret life of components" chapter...

Below is some code to reproduce the problem and a workaround.

Timo

Main.html:

<html>
  <head>
    <title>TextFieldBugRepro</title>
  </head>
  <body>
    <webobject name="Form">
      Enter something to toggle conditional: 
      <webobject name="WOTextField1" /> (initally empty) <br />
      <webobject name="Conditional">
        <webobject name="WOTextField2" /> (normal WOTextField, should be "foo" initially) <br />
        <webobject name="WOTextField3" /> (WOTextFieldWithWorkaround, should be "bar" initially) <br />
        <webobject name="Link">Start over</webobject> <br />
      </webobject>
      <webobject name="SubmitActionButton" />
    </webobject>
  </body>
</html>

Main.wod:

WOTextField1 : WOTextField {
  name = "text1";
  value = text1;
}

WOTextField2 : WOTextField {
  name = "text2";
  value = text2;
  readonly = true;
}

WOTextField3 : WOTextFieldWithWorkaround {
  name = "text3";
  value = text3;
  readonly = true;
}

Conditional : WOConditional {
  condition = text1;
}

Link : WOHyperlink {
  pageName = "Main";
}

SubmitActionButton : WOSubmitButton {
  name = "submitButton";
  action = submitAction;
}

Form : WOForm {
}

Main.java:

public class Main extends WOComponent {
private String text1 = null, text2 = "foo", text3 = "bar";

public Main(WOContext context) {
super(context);
System.out.println("Main instanciated");
}

public WOActionResults submitAction() {
System.out.println("Main.submitAction, formValueKeys: " + context().request().formValueKeys());
return context().page();
}

public void setText1(String text1) {
System.out.println("Main.setText1(" + this.text1 + " -> " + text1 + ")");
this.text1 = text1;
}

public String text1() {
return text1;
}

public void setText2(String text2) {
System.out.println("Main.setText2(" + this.text2 + " -> " + text2 + ")");
// new RuntimeException("trace").printStackTrace(System.out);
this.text2 = text2;
}

public String text2() {
return text2;
}

public void setText3(String text3) {
System.out.println("Main.setText3(" + this.text3 + " -> " + text3 + ")");
// new RuntimeException("trace").printStackTrace(System.out);
this.text3 = text3;
}

public String text3() {
return text3;
}
}

WOTextFieldWithWorkaround.java:

public class WOTextFieldWithWorkaround extends WOTextField {

public WOTextFieldWithWorkaround(String arg0, NSDictionary arg1, WOElement arg2) {
super(arg0, arg1, arg2);
}

@Override
public void takeValuesFromRequest(WORequest worequest, WOContext wocontext) {
String name = nameInContext(wocontext, wocontext.component());
if (worequest.formValueKeys().containsObject(name)) {
super.takeValuesFromRequest(worequest, wocontext);
}
}

}

 _______________________________________________
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: Bug in WOTextField?
      • From: Alexander Spohr <email@hidden>
  • Prev by Date: Fwd: Why I hate Java Client (I hope this could help you)
  • Next by Date: Re: Bug in WOTextField?
  • Previous by thread: Fwd: Why I hate Java Client (I hope this could help you)
  • Next by thread: Re: Bug in WOTextField?
  • Index(es):
    • Date
    • Thread