Re: WO Tutorial - Component Communication
Re: WO Tutorial - Component Communication
- Subject: Re: WO Tutorial - Component Communication
- From: Cameron Knowlton <email@hidden>
- Date: Mon, 6 Jan 2003 14:37:56 -0700
Wow: Bob likes to eat Oatmeal
That's cool.
You were right, I'd missed the nextPage.setUser(user); in my submitChanges method.
public Main submitChanges() {
Main nextPage = (Main)pageWithName("Main");
// Initialize your component here.
nextPage.setUser(user);
return nextPage;
}
I'd somehow missed the instantiation in Main.java, too, thus the user==null assertion.
Thanks for your patience, I learned a lot chasing down this little exercise. Sounds like Targets are worth studying, they haven't been mentioned yet in my lowly studies.
Very professional system, I'm impressed with WebObjects so far.
cheers,
Cameron Knowlton
>Targets are confusing. When Application Server is selected from the targets menu, it should be checked, if your application's name is selected from the targets menu, then it is typically not checked.
>
>If user is not supposed to be null, then you would need to take a look at the section of code responsible for creating a new User object. It's been a long time since I've done this example, so I don't exactly remember how it goes. But I assume that you are either clicking a link, or submitting a form that should be tied to an action which creates a new User object. Is this action being called?
>
>If you would like, you can send me your project. That would probably be the fastest way for me to help.
>
>patrick
>
>
>
>On Monday, January 6, 2003, at 12:49 PM, Cameron Knowlton wrote:
>
>>oooookkkk, I don't get that. should the User class be checked?
>>
>>the "user=null" is a test... it shouldn't be null, it's supposed to exist. The WOConditional is based on that, but it's failing... it's null. it's nothing. thus the test. Why, though, is it null? it shouldn't be null.
>>
>>Thus the test.
>>
>>thanks,
>>Cameron Knowlton
>>email@hidden
>>
>>>The checkboxes refer to whether or not a file has been added to a particular target. There is a targets menu toward the top of Project Builder. If you change the target to Application Server, you will see most of the checkboxes checked. If you change it back to your application, most will be unchecked. Typically when you add a file to an application, you will specify the "Application Server" target. You can probably get more information if you search the archives of the WebObjects-Dev list at OmniGroup.com.
>>>
>>>I am not understanding what the problem is. When you got back "user == null" in the console, was that what was expected? If so, did you verify the 'negate' binding of the WOConditional? Is the problem that the incorrect information is being shown on the page that is returned, or is the wrong page being returned?
>>>
>>>It is certainly just a very small mistake somewhere.
>>>
>>>patrick
>>>
>>>
>>>On Sunday, January 5, 2003, at 11:07 PM, Cameron Knowlton wrote:
>>>
>>>>I put in a diagnotistic test in the noDataEntered method; sure enough, I get back "user == null".
>>>>
>>>>Below is my Main.java file... sorry for those on digest.
>>>>
>>>>Quick question: In the Groups & Files / Classes folder, I have listed:
>>>>
>>>>Application.java
>>>>Session.java
>>>>DirectAction.java
>>>>User.java
>>>>
>>>>To the left of these, there's a checkbox... but I can't find in the documentation what that indicates.
>>>>
>>>>thanks,
>>>>Cameron Knowlton
>>>>
>>>>
>>>>------------
>>>>
>>>>//
>>>>// Main.java: Class file for WO Component 'Main'
>>>>// Project ComponentCommunication
>>>>//
>>>>// Created by cameronk on Sun Jan 05 2003
>>>>//
>>>>
>>>>import com.webobjects.foundation.*;
>>>>import com.webobjects.appserver.*;
>>>>import com.webobjects.eocontrol.*;
>>>>import com.webobjects.eoaccess.*;
>>>>
>>>>public class Main extends WOComponent {
>>>> protected User user;
>>>>
>>>> public Main(WOContext context) {
>>>> super(context);
>>>> }
>>>>
>>>>
>>>>
>>>>/**
>>>>* Determines whether the user has entered data into <code>user</code>.
>>>>*
>>>>* @return true when the user has entered data into
>>>>* user.
>>>>**/
>>>>
>>>> public boolean noDataEntered() {
>>>> boolean noDataEntered;
>>>> if (user == null) {
>>>> System.out.println("user == null");
>>>> }
>>>> else {
>>>> if (user.entryIncomplete()) {
>>>> System.out.println("user.entryIncomplete");
>>>> }
>>>> }
>>>> if (user == null || user.entryIncomplete()) {
>>>> noDataEntered = true;
>>>> }
>>>> else {
>>>> noDataEntered = false;
>>>> }
>>>> return noDataEntered;
>>>> }
>>>>
>>>>
>>>> public User user()
>>>> {
>>>> return user;
>>>> }
>>>> public void setUser(User newUser)
>>>> {
>>>> user = newUser;
>>>> }
>>>>
>>>> public UserEdit editUser()
>>>> {
>>>> UserEdit nextPage = (UserEdit)pageWithName("UserEdit");
>>>>
>>>> if (user == null) {
>>>> user = new User();
>>>> }
>>>>
>>>> // Send user to the UserEdit page.
>>>> nextPage.setUser(user);
>>>>
>>>> return nextPage;
>>>> }
>>>>
>>>>}
>>>>
>>>>------------
>>>>
>>>>>Did you set the 'negate' binding on your WOConditional? It should either be un-set, or set to 'false' so that the content within the WOConditional will be shown only if noDateEntered() returns true.
>>>>>
>>>>>In reply to your other message, I am not a C programmer, but it looks as though you have your methods in the correct place.
>>>>>
>>>>>public class Main extends WOComponent {
>>>>>
>>>>> public Main(WOContext context) {
>>>>> super(context);
>>>>> }
>>>>>
>>>>> // Your methods here
>>>>>
>>>>>}
>>>>>
>>>>>If they were terribly out of place, I image the compiler would complain.
>>>>>
>>>>>patrick
>>>>>
>>>>>
>>>>>
>>>>>On Sunday, January 5, 2003, at 04:13 PM, Cameron Knowlton wrote:
>>>>>
>>>>>>p.s. I'm not getting an error message, but after submitting the form, I get the 'No data entered' message.
>>>>>>
>>>>>>Checking the logic, I find that the assertion:
>>>>>>
>>>>>> if (user == null)
>>>>>>
>>>>>>is testing true, so the WOConditional fires wrong.
>>>>>>
>>>>>>
>>>>>>thanks again,
>>>>>>Cameron Knowlton
>>>>>>
>>>>>>>Looks ok to me as long as you have something like...
>>>>>>>
>>>>>>> protected User user;
>>>>>>>
>>>>>>>... in Main.java, and the User.java class is added to the application server.
>>>>>>>
>>>>>>>What error are you getting? Every so often it help to "Clean" your application by clicking on the clean (broom) button in Project Builder.
>>>>>>>
>>>>>>>patrick
>>>>>>>
>>>>>>>
>>>>>>>On Sunday, January 5, 2003, at 01:23 PM, Cameron Knowlton wrote:
>>>>>>>
>>>>>>>>Greetings, and a question from the newbie:
>>>>>>>>
>>>>>>>>I'm working through the tutorial, but I'm stuck on the final run of the ComponentCommunication project.
>>>>>>>>
>>>>>>>>Specifically, the noDataEntered() function is failing on its test of
>>>>>>>>
>>>>>>>>if (user == null)
>>>>>>>>
>>>>>>>>It would seem that my user doesn't get instantiated. I do have the code in Main.java:
>>>>>>>>
>>>>>>>>----------
>>>>>>>>public UserEdit editUser()
>>>>>>>>{
>>>>>>>> UserEdit nextPage = (UserEdit)pageWithName("UserEdit");
>>>>>>>>
>>>>>>>> if (user == null) {
>>>>>>>> user = new User();
>>>>>>>> }
>>>>>>>>
>>>>>>>> // Send user to the UserEdit page.
>>>>>>>> nextPage.setUser(user); return nextPage;
>>>>>>>>}
>>>>>>>>----------
>>>>>>>>
>>>>>>>>Any ideas?
>>>>>>>>
>>>>>>>>thanks in advance,
>>>>>>>>Cameron Knowlton
>>>>>>>>_______________________________________________
>>>>>>>>webobjects-dev mailing list | email@hidden
>>>>>>>>Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
>>>>>>>>Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.