Posted by
byersa on
Dec 19, 2005; 5:10pm
URL: http://ofbiz.116.s1.nabble.com/Dev-Lookup-Form-Widget-Question-tp166392p166395.html
Hey Micheal,
I got to thinking that your idea for fixing this was worth putting in.
Would you mind testing it before it gets committed? I hacked up two
patch files because I had other changes in them; so you will have to
patch them by hand. And I included a method from the fieldlookup.js
that needs to be replaced.
If you can't get to it, it will eventually make itself into the base.
Thanks,
-Al
P.S. This will make you an official deputy psuedo-committer. Your secret
decoder ring will be sent by special courier. :0)
Index: src/org/ofbiz/widget/form/ModelFormField.java
===================================================================
--- src/org/ofbiz/widget/form/ModelFormField.java (revision 6278)
+++ src/org/ofbiz/widget/form/ModelFormField.java (working copy)
public static class LookupField extends TextField {
- protected String formName;
+ protected FlexibleStringExpander formName;
protected String descriptionFieldName;
protected String targetParameter;
public LookupField(Element element, ModelFormField
modelFormField) {
super(element, modelFormField);
- this.formName = element.getAttribute("target-form-name");
+ this.formName = new
FlexibleStringExpander(element.getAttribute("target-form-name"));
this.descriptionFieldName =
element.getAttribute("description-field-name");
this.targetParameter =
element.getAttribute("target-parameter");
}
@@ -2645,8 +2683,8 @@
formStringRenderer.renderLookupField(buffer, context, this);
}
- public String getFormName() {
- return this.formName;
+ public String getFormName(Map context) {
+ return this.formName.expandString(context);
}
public List getTargetParameterList() {
Index: src/org/ofbiz/widget/html/HtmlFormRenderer.java
===================================================================
--- src/org/ofbiz/widget/html/HtmlFormRenderer.java (revision 6278)
+++ src/org/ofbiz/widget/html/HtmlFormRenderer.java (working copy)
@@ -1655,7 +1688,7 @@
buffer.append(modelFormField.getParameterName(context));
buffer.append(", '");
}
- buffer.append(lookupField.getFormName());
+ buffer.append(lookupField.getFormName(context));
buffer.append("'");
List targetParameterList = lookupField.getTargetParameterList();
if (targetParameterList.size() > 0) {
framework/images/webapp/images/fieldlookup.js:
function lookup_popup2 (view_name) {
var argString = "";
if (this.args.length > 2) {
for(var i=2; i < this.args.length; i++) {
argString += "&parm" + (i-2) + "=" + this.args[i];
}
}
var sep = "?";
if (view_name.indexOf("?") >= 0) {
sep = "&";
}
var obj_lookupwindow = window.open(view_name + sep + 'id=' + this.id
+ argString,'FieldLookup',
'width=700,height=550,scrollbars=yes,status=no,resizable=yes,top='+my+',left='+mx+',dependent=yes,alwaysRaised=yes');
obj_lookupwindow.opener = window;
obj_lookupwindow.focus();
}
Michael Irving wrote:
>Thanks Al.
>
>When I used "target-parameter", it doesn't appear that call_fieldlookup2 can
>handle the third parameter. Was fieldlookup.js also modified to support
>this?
>
>function call_fieldlookup2(target, viewName) {
> var fieldLookup = new fieldLookup1(target);
> fieldLookup.popup2(viewName);
>}
>
>-----Original Message-----
>From:
[hidden email] [mailto:
[hidden email]] On
>Behalf Of Al Byers
>Sent: Friday, December 16, 2005 5:21 PM
>To: OFBiz Project Development Discussion
>Subject: Re: [OFBiz] Dev - Lookup Form Widget Question
>
>Michael,
>
>There is an attribute to lookup that is not in the schema file. It is
>"target-parameter". I would commit it, but I am having trouble
>connecting to the svn server.
>
>It should be the name of a field in the form. In your case, "partyId".
>It will get the value of that field and send it to the server as
>"parm0=<value>". So, it is limited to fields in your form, but you
>should be able to add just about any hidden field if you need to.
>
>You can have more than one parameter in target-parameter. Separate them
>with ",".
>
>-Al
>
>
>Michael Irving wrote:
>
>
>
>>Is there a way to pass a parm to a lookup form?
>>
>>I'm trying to have the lookup for filter out records based on a
>>partyId. I was looking to have my main form do something like this:
>>
>><field name="workEffortId" title="Task">
>>
>><lookup
>>target-form-name="LookupPartyAssginedWorkEffort?partyId=${partyId}"/>
>>
>></field>
>>
>>Then, the bsh for the form would be able to query
>>WorkEffortAndPartyAssign for the given partyId..but that didn't work.
>>
>>Any ideas would be GREATLY appreciated
>>
>>
>>
>
>
>_______________________________________________
>Dev mailing list
>
[hidden email]
>
http://lists.ofbiz.org/mailman/listinfo/dev>
>
>_______________________________________________
>Dev mailing list
>
[hidden email]
>
http://lists.ofbiz.org/mailman/listinfo/dev>
>
>
_______________________________________________
Dev mailing list
[hidden email]
http://lists.ofbiz.org/mailman/listinfo/dev