• 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
Re: Trying to create a dynamic url with the components action?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trying to create a dynamic url with the components action?


  • Subject: Re: Trying to create a dynamic url with the components action?
  • From: James Cicenia <email@hidden>
  • Date: Mon, 7 May 2007 08:32:35 -0500

OK OK !!

My hands have been slapped and I immediately stopped. Though I thought it might have worked.
Anyway, after refactoring my design and code I have another problem. Probably has to do with the
RR loop thing again.


So after refactoring my code, I figured out how to use that component, get the url from it, and embed
it in my javascript YUI Treeview. Everything seems to work great except for one big confusing problem.
My link's action binding isn't being fired.


Here is the scenario:

Page
	DocumentTree Component
		Node Component
			NXDowloadComponent
				NXHyperlink

So it all renders correctly and even the href that is generated sure looks correct. However, when I
click the hyperlink, it just won't fire its action method.


I doubled checked all the bindings. Is it because it is being rendered dynamically via javascript
at the browser level?


Any thoughts would be very helpful

Thanks
James Cicenia





On May 6, 2007, at 8:03 PM, Jean-François Veillette wrote:

James, stop it, It can't be done like that. Think about another way to do it.

There are many options to solve this problem, but not knowing anymore on how your app is organized, I would try to give extra argument to the generated hyperlink (http://www.aa.aa/cgi-bin/ WebObjects/xxx.woa/wo/1.2.3?b1=true&b2=false&b3=true&data=key)

public WOComponent doMyStuffWithURL() {
String key = ... // get the key value from request url (sorry I dont know the api from the top of my head)
...
return doMyStuff(key, b1, b2, b3);
}


public WOComponent doMyStuff(String key, boolean b1, boolean b2, boolean b3 ) {
NXFileDownload fd = new NXFileDownload(context());
Item item = itemForKey(key); // this is a method to return you the right item, based on some key comming from the url arguments.
fd.setValueForBinding( item.title(), "filenameForClient");
fd.setValueForBinding(new Boolean(b1),"useDisplayOnlyIfDataExists");
fd.setValueForBinding(new Boolean(b2),"useShowLengthOfDownload");
fd.setValueForBinding(new Boolean(b3),"useShouldDisplayInBrowser");
fd.setValueForBinding( item.projectDocumentObject().documentObject (), "data");
return fd;
}


The hyperlink all have the action bound to doMyStuffWithURL, and you add your extra arguments the usual way.

- jfv

Le 07-05-06 à 18:08, Chuck Hill a écrit :

Ever listen to The Smiths?  How soon is now?


On May 6, 2007, at 7:49 AM, James Cicenia wrote:

I best explain this better...

I have someone else's component.

And me thinks you are misunderstanding it and/or misusing it.


So what I have to do is create my complete
url in java code. Normally I use something like componentActionURL (). However
this component has only:


public WOComponent actionDownloadThisFile()
{
returnDownloadInsteadOfComponent = true;
WOComponent componentToReturn = componentValueForBinding ("action", context().page());
return componentToReturn;
}


There is no component in the html. Just one generic component that needs to render a url.

So I did this in my java code:


NXFileDownload fd = new NXFileDownload(context());
fd.setValueForBinding( item.title(),"filenameForClient");
fd.setValueForBinding(new Boolean (false),"useDisplayOnlyIfDataExists");
fd.setValueForBinding(new Boolean (true),"useShowLengthOfDownload");
fd.setValueForBinding(new Boolean (false),"useShouldDisplayInBrowser");
fd.setValueForBinding( item.projectDocumentObject ().documentObject(),"data");

OK, that is just nuts. Doesn't that just scream NOOOOOOO at you? I can hear it from here. ;-)



So now what do I do to render its url?

I was hoping for something like fd.componentActionURL() .. BUT it doesn't have one?!

This looks like a component that you put on a page and it generates its own UI ("click here to download" or whatever). You seem to be trying to bind it to some other link that you have created. You might be able to torture it into this, but why?


<webobject name="FileDownload"/>

FileDownload : NXFileDownload{
	filenameForClient = item.title;
	useDisplayOnlyIfDataExists = false;
	useShowLengthOfDownload = true;
	useShouldDisplayInBrowser = false;
	data = item.projectDocumentObject.documentObject;
}

If you really want to not use it like that, you will have better luck sub-classing it and giving it a UI like that.

Chuck


On May 6, 2007, at 12:12 AM, Lachlan Deck wrote:

Hi James,

On 06/05/2007, at 8:30 AM, James Cicenia wrote:

I am needing to create my own URLs dynamically that call a components method.
How do I do this?

I assume you've a reusable component you're wanting to drop on a page?


Say I have a component that renders the url that is for the delete method in that component?

perhaps something like this is what you're after.

-- html --
<webobject name="CanDelete"><webobject name="DeleteAction">...</ webobject></webobject>


-- wod --
CanDelete: WOConditional {
	condition = hasDeleteableParent;
}
DeleteAction: WOHyperlink {
	action = deleteAction;
}

-- java --
public WOActionResults deleteAction() {
	return deleteableParent().deleteRecord();
	// or
	return performParentAction( "relevantKey" );
}

public YourInterface deleteableParent() {
return parent() instanceof YourInterface ? ( YourInterface ) parent() : null;
}


public boolean hasDeleteableParent() {
	return deleteableParent() != null;
}

with regards,
--

Lachlan Deck



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40jimijon.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:
40global-village.net


This email sent to email@hidden


--

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems. http://www.global-village.net/products/ practical_webobjects





_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


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
  • Follow-Ups:
    • Re: Trying to create a dynamic url with the components action?
      • From: Jean-François Veillette <email@hidden>
References: 
 >Trying to create a dynamic url with the components action? (From: James Cicenia <email@hidden>)
 >Re: Trying to create a dynamic url with the components action? (From: Lachlan Deck <email@hidden>)
 >Re: Trying to create a dynamic url with the components action? (From: James Cicenia <email@hidden>)
 >Re: Trying to create a dynamic url with the components action? (From: Chuck Hill <email@hidden>)
 >Re: Trying to create a dynamic url with the components action? (From: Jean-François Veillette <email@hidden>)

  • Prev by Date: WOPopup will not give value to DB
  • Next by Date: Re: Trying to create a dynamic url with the components action?
  • Previous by thread: Re: Trying to create a dynamic url with the components action?
  • Next by thread: Re: Trying to create a dynamic url with the components action?
  • Index(es):
    • Date
    • Thread