Hi
How can i override OK button in my DioalogContainer? I kept seperate button "SUBMIT" to todo my logic, but i dont want seperate button. I want to use OK button in dialodcontainer. How can i do that plz tell me.
Take a view on jsp page of DialogContainer - there is a button OK, witch calls method onOk(Control button, ArgumentList args)
Follow these steps:
void onOk(Control button, ArgumentList args) {
super.onOk(button, args);
// some logic
}
I tride wat u say, but am geting "Cannot create control: text1 in this state : Cannot create control: text1 in this state" this error.
Actually i wrote "submit" button following is the code
public void onMybuttonclick(Button button,ArgumentList arg) { Text name=(Text) getControl("text1",Text.class); Text path=(Text) getControl("text",Text.class); String name1=name.getValue(); String path1=path.getValue(); System.out.println("NAME="+ name1); System.out.println("PATH="+ path1); try { IDfClientX X=new DfClientX(); IDfFolder f=(IDfFolder)getDfSession().newObject("dm_folder"); f.setObjectName(name1); f.link(path1); f.save(); } catch(Exception e){ e.printStackTrace();} return false; }
now i want to execute this logic when i am click OK button in dialogcontainer wat to do?
Where do you have controls "text", "text1"? are they on component's jsp or container's jsp?
To execute logic when button "OK" pressed - change the name of method into "onOk".
"onMyButtonclicked" is component's jsp. I changed onMyButtonclicked to onOk i get this error
java.lang.NullPointerExceptionat com.documentum.web.formext.component.DialogContainer.canCommitChanges(DialogContainer.java:84)
Post here xml, jsp, java of your component and container.
Am sending all my custom files as attachment.
Well, I've looked at your WKD and I catch the problem: Container asked component's controls.
Use follow code to get component from container and then get controls from component.
package com.crimson;
import com.documentum.com.DfClientX;import com.documentum.com.IDfClientX;import com.documentum.fc.client.IDfFolder;import com.documentum.web.common.ArgumentList;import com.documentum.web.form.Control;import com.documentum.web.form.control.Text;import com.documentum.web.formext.component.Component;import com.documentum.web.formext.component.Container;import com.documentum.web.formext.component.DialogContainer;public class dialogcontainer extends DialogContainer{ public void onInit (ArgumentList args) { super.onInit(args); } /*public void onCancel (Control button, ArgumentList args) { super.onCancel(button, args); setComponentReturn(); }*/ public void onOk(Control button, ArgumentList args) { super.onOk(button, args); Component component = getContainedComponent(); Text name=(Text) component.getControl("text1",Text.class); Text path=(Text) component.getControl("text",Text.class); String name1=name.getValue(); String path1=path.getValue(); System.out.println("NAME="+name1); System.out.println("PATH="+path1); try { IDfClientX X=new DfClientX(); IDfFolder f=(IDfFolder)getDfSession().newObject("dm_folder"); f.setObjectName(name1); f.link(path1); f.save(); System.out.println("folder created successfully"); } catch(Exception e){ e.printStackTrace();} setComponentReturn(); }}
WHY do you require this? What non standard action requires such a strange customisation?
Typically you should only add logic to a custom COMPONENT which is contained within a CONTAINER. The containers do provide the dialog navigation controls (OK, CANCEL, NEXT, BACK, ...) but these call contained component methods.
The method "public boolean onCommitChanges()" of the COMPONENT is where you should add the logic for the OK button of a dialog.
As you said i wrote my logic in onCommitChanges() method and in my container behaviour class i wrote the following code
public class dialogcontainer extends DialogContainer{ public void onInit (ArgumentList args) { super.onInit(args); } public void onOk(Control button, ArgumentList args) { super.onOk(button, args); Component component = getContainedComponent(); component.onCommitChanges(); System.out.println("folder created =>"); setComponentReturn(); }
but am geting following error
java.lang.NullPointerExceptionat com.documentum.web.formext.component.DialogContainer.canCommitChanges(DialogContainer.java:84)at com.documentum.web.formext.component.DialogContainer.canCommitChanges(DialogContainer.java:84)at com.documentum.web.formext.component.DialogContainer.canCommitChanges(DialogContainer.java:84)at com.documentum.web.formext.component.DialogContainer.updateControls(DialogContainer.java:193)at com.documentum.web.formext.control.component.ComponentIncludeTag.renderEnd(ComponentIncludeTag.java:170)at com.documentum.web.form.ControlTag.doEndTag(ControlTag.java:802)
i wrote canCommitChanges() method also in my component behaviour class but same error is coming.plz help me
You are doing nothing of value with your custom DialogContainer... so get rid of it and let the WDK framework work as designed. The DialogContainer already has code to call the component onCommitChanges method.
Unless you have some special processing, for example new doc/folder or import where it is not appropiate to revisit one of the contained components there is no sense or need to modify container behaviour