Hi,
Well my action methods match this signature... Here's my class :
public class ListInvoiceController extends ERDBranchDelegate {
private WOComponent sender;
private WOComponent sender() {
return sender;
}
private void setSender(WOComponent sender) {
this.sender = sender;
}
private D2WContext d2wContext() {
return (D2WContext) sender().valueForKey("d2wContext");
}
private EOEnterpriseObject object() {
return (EOEnterpriseObject)d2wContext().valueForKey("object");
}
public WOComponent copyButton (WOComponent sender){
setSender(sender);
Invoice invoice = (Invoice)object();
EOEnterpriseObject invoiceCopy = invoice.copy(null);
EditPageInterface epi =
D2W.factory().editPageForNewObjectWithEntityNamed(Invoice.Keys.ENTITY_NAME,
sender.session());
epi.setObject(invoiceCopy);
((InvoiceWizardPage) epi).isCopy = true;
return (WOComponent) epi;
}
public WOComponent pdfButton(WOComponent sender){
setSender(sender);
Invoice invoice = (Invoice) object();
PDFInvoice pdfPage = (PDFInvoice)
WOApplication.application().pageWithName(PDFInvoice.class.getName(),
(WOContext) sender.context().clone());
pdfPage.setInvoice(invoice);
return pdfPage;
}
}
my rules :
80 : (pageConfiguration like 'List*Invoice' and session.isSubjectAdmin =
'1') => actions = {"left" = ("controllerAction"); "right" =
("inspectAction"); } [com.webobjects.directtoweb.Assignment]
100 : propertyKey = 'controllerAction' => componentName =
"ERDControllerButton" [com.webobjects.directtoweb.Assignment]
105 : pageConfiguration like 'List*Invoice' => pageController =
"ListInvoiceController" [er.directtoweb.ERDDelayedObjectCreationAssignment]
And when I go to a list page which have this controller, I've noticed
that the rules are fired . I must have missed something but I don't know
where... Do you maybe have an exemple in which I could search?
Thanks a lot!
Le 07/09/12 20:37, Ramsey Gurley a écrit :
You probably don't need a rule. The branch delegate will supply the
default branch choices. You just have to make sure your action methods
match the signature
public WOComponent myButton(WOComponent sender)
Ramsey
On Sep 7, 2012, at 7:31 AM, Antoine Berry wrote:
Hello,
Actually I wrote my rules again and now there's no exceptions
anymore. I don't know why that didn't work before, I must have put
something wrong... But now that the rules are fired, the buttons
which I would want to add in my list aren't display. What are the
rules to display the custom buttons? is it the "branchChoices" rule?
All my rules about this pageController :
80 : ((pageConfiguration like 'List*Invoice' or pageConfiguration
like 'ListCustomer' or pageConfiguration like 'ListBankAccount' or
pageConfiguration like 'ListCompany') and session.isSubjectAdmin =
'1') => actions = {"left" = ("inspectAction", "deleteAction");
"right" = ("controllerAction"); } [com.webobjects.directtoweb.Assignment]
100 : propertyKey = 'controllerAction' => componentName =
"ERDControllerButton" [com.webobjects.directtoweb.Assignment]
105 : entity.name <http://entity.name> = 'Invoice' => pageController
= "fr.sophiacom.application.ui.delegates.ListInvoiceController"
[er.directtoweb.ERDDelayedObjectCreationAssignment]
Le 06/09/12 19:14, Ramsey Gurley a écrit :
On Sep 6, 2012, at 2:22 AM, Antoine Berry wrote:
Hello Ramsey,
Thank you about the quick answer. I understood why you told me not
to use the nextPageDelegate. I tried a couple of things with it,
and you were right, embedded component are already perfectly
managed. So I followed your advice and tried to solve my problem
with a pageController, which seems way easier (and smarter).
I found an old email on the web (by Anjo Krank :
http://www.digipedia.pl/usenet/thread/17625/14191/) which explain
how to add a custom button on a list. The rule where I set the
pageController is fired, but my actions rule throws an exception :
*Reason:* <fr.sophiacom.sophiacture.business.Invoice 0x36cebdbf>
valueForKey(): lookup of unknown key: 'controllerAction'. This
class does not have an instance variable of the name
controllerAction or _controllerAction, nor a method of the name
controllerAction, _controllerAction, getControllerAction, or
_getControllerAction
What does the stack trace look like?
I kind of understand why this exception occurred but I can't find
the solution. The email is quite old now so I thought that maybe
something has changed since?
my rules for the controller :
80 : ((pageConfiguration like 'List*Invoice' or pageConfiguration
like 'ListCustomer' or pageConfiguration like 'ListBankAccount' or
pageConfiguration like 'ListCompany') and session.isSubjectAdmin =
'1') => actions = {"left" = ("inspectAction", "controllerAction");
"right" = ("deleteAction"); } [com.webobjects.directtoweb.Assignment]
105 : entity.name <http://entity.name/> = 'Invoice' =>
pageController =
"fr.sophiacom.application.ui.delegates.ListInvoiceController"
[er.directtoweb.ERDDelayedObjectCreationAssignment]
100 : propertyKey = 'controllerAction' => componentName =
"ERDControllerButton" [com.webobjects.directtoweb.Assignment]
PS : for a list I set the actions with "left = (...)" and "right =
(...)", but what about an inspect page, or an edit page? I tried a
couple of things like "bottom = (...)" for exemple but it doesn't
seem to work... Do you know which keyword I have to use?
Le 04/09/12 19:12, Ramsey Gurley a écrit :
Hi Antoine,
You almost had it. Use the entire class path and use the
ERDDelayedObjectCreationAssignment instead of Assignment. That will generate
the object using the default constructor.
Be aware though... if you are working with embedded D2W pages with a bound
action binding, you can't set the nextPageDelegate because it is already set.
In most cases, I don't use the nextPageDelegate. I use the pageController
instead.
Ramsey
On Sep 4, 2012, at 9:54 AM, Antoine Berry wrote:
Hello everybody,
I'm working on a D2W application, and I'm trying to override most of the
nextPage default behavior. I've created a delegate which reorient the user on
an inspect page of his object after its creation (for exemple), and first i've
set it in the code (through the navigationController), and it worked quite well.
But I would want to do it directly in the rules, cause I don't have direct access on every pages, like
the edit pages for exemple. So I tried to add a rule like "100 : pageConfiguration like
'CreateMyObject' => nextPageDelegate <= InspectAfterCreationDelegate". But there is a
ClassCastException : "cannot cast from java.lang.String to
com.webobjects.directtoweb.NextPageDelegate". And it's the same exception when I put the complete
path of my class...
I've tried different things, but I can't find a solution, and I don't know
where to search. I'm new on the mailing list so I'm sorry if this subject has
been discussed before (maybe somebody have an archive about a similar
discussion).
Antoine
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/rgurley%40smarthealth.com
This email sent [email protected]
--
Antoine Berry
--
Antoine Berry
--
Antoine Berry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]