Re: Custom PopUp Problems
Re: Custom PopUp Problems
- Subject: Re: Custom PopUp Problems
- From: Ken Anderson <email@hidden>
- Date: Wed, 26 Apr 2006 13:29:56 -0400
First off, welcome to WebObjects!
On Apr 26, 2006, at 1:13 PM, Scott Winn wrote:
Hi WOList,
I am relatively new to WebObjects (and Java for that matter).
I am trying to create a reusable component that is essentially a
WOPopUpButton with a custom fetch that generates the list
attribute. That part is working. When I put this component in a
page, it will be used to edit a relationship attribute of the
Object the page is displaying. I am not using WOToOneRelationship
because of the custom fetch logic.
I guess my first question is, why are you coupling a UI element with
your model? I would really like to hear more about the custom fetch
logic, and why it makes sense to have the rolled up into a component.
WOPopUpButton handles all off the necessary selection logic if you
let it. The typical way to bind a pop-up list would be to bind the
'list' attribute to either an NSArray in your component, or a method
that fetches the correct set of objects. You would bind 'item' to an
instance variable that corresponds to a single item in your array,
and 'selection' to the relationship. As an example, if you have a
page that allows you to set the teacher relationship of a student
where the teachers are fetched with custom logic, you could have java
that looks like this:
public Teacher teacher;
public Student student;
private NSArray teachers;
public NSArray teachers() {
if (teachers == null) {
teachers = <ANY CUSTOM LOGIC YOU WANT>;
}
return teachers;
}
Assuming the Student EO has a to-one relationship called 'teacher',
your bindings would be:
list = teachers
item = teacher
selection = student.teacher
displayString = teacher.fullName
When entering the page, the pop up would automatically be set to the
correct teacher for the student. When submitting the form it should
be on, whatever teacher was selected would now be connected to the
student's teacher relationship.
Hopefully that helps!
Ken
I have two problems. . .
1) I have the Object on an EditObject page, and I want to tell the
Custom Pop-up Component to "select" the current value that is part
of that Object (see option 3 below).
<select>
<option value="1">A Value</option>
<option value="2">A Value</option>
<option value="3" selected="selected">My Object's Value</option>
<option value="4">A Value</option>
</select>
I have no idea how to get WO to put selected="selected" on correct
list option.
2) Since it is a custom object and has no default bindings, I don't
how or what to hook it to on my EditObject page so that the Object
will get the user selected value when I save it.
I have preformed due diligence trying to find my own answer, but
all the info I could find either didn't seem to apply, or I just
didn't understand it. Any and all help is appreciated.
Scott
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40anderhome.com
This email sent to email@hidden
_______________________________________________
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