Skip to Content
0
Former Member
Mar 27, 2006 at 01:21 PM

Select All command

29 Views

Hi,

I try hard to implement a uicommand that permits to select all the objects from my basket iview (as yet i have to select the checkboxes one by one).

Although i did what has been said in the sdn ()

the action does not work.

this is the classe I have implemented, is there something wrong with it?

public class KMUISelectAllCommand extends AbstractCommand

implements BasketConstants

{

private final static Location log = Location.getLocation(KMUISelectAllCommand.class);

private List values;

private String RESOURCE_TYPE;

public KMPUISelectAllCommand()

{

values = null;

RESOURCE_TYPE = "resourcetype";

log.debugT(Category.APPLICATIONS, "KMUISelectAllCommand...");

}

public LinkAttributes getLinkAttributes()

{

String sURL = "javascript:var f = parent.document.forms[0];var CHECKBOX = 'checkbox';for(i=0;i<f.length;i++){if(f.elements.type==CHECKBOX){f.elements.checked=true;var imgElement=parent.document.getElementById(f.elements.name + '_img');imgElement.className='urImgCbgImgChk';}}";

return new LinkAttributes(sURL,"_this",true);

}

public String[] getTargetParameters()

throws WcmException

{

String result[] = new String[1];

result[0] = super.resource.getRID().getPath();

return result;

}

public boolean isExecutable()

{

return true;

}

public boolean raisesEvent()

{

return false;

}

public ICommand getNewInstance()

{

return initNewInstance(new KMUISelectAllCommand());

}

public void setTargetParameters(List values, IResourceContext context)

{

this.values = values;

super.context = context;

}

public IRenderingEvent execute(IScreenflowData data)

throws WcmException

{

log.debugT(Category.APPLICATIONS, "KMUISelectAllCommand execute(data)");

TextView tv = new TextView("tvid");

tv.setText("Do you really want to do this?");

ConfirmComponent cc = new ConfirmComponent(

ConfirmComponent.OK_CANCEL,

this.context.getLocale(),

tv

);

String sRid = (String)this.values.get(0);

RID rid = RID.getRID(sRid, null);

OneStepScreenflow oscf = new OneStepScreenflow(

data,

this.getAlias(),

rid,

cc

);

return oscf.execute();

//return new RenderingEvent(null);

}

public IRenderingEvent execute(IResource res, Event event) throws WcmException {

log.debugT(Category.APPLICATIONS, "KMUISelectAllCommand execute(resource, event)");

if (event instanceof ConfirmEvent) {

ConfirmEvent cce = (ConfirmEvent)event;

if (ConfirmEvent.CHOICE_YES.equals(cce.getChoice())) {

// do the action here ...

return new InfoEvent(Status.OK, "Done !");

} else if (ConfirmEvent.CHOICE_NO.equals(cce.getChoice())) {

return ConfirmComponent.onNo(event, res.getContext().getLocale());

} else if (ConfirmEvent.CHOICE_CANCEL.equals(cce.getChoice())) {

return ConfirmComponent.onCancel(event, res.getContext().getLocale());

}

}

return new InfoEvent(Status.ABORT, "Aborted.");

}

}