Save as Word Document | Find | English | Portugues(Brasil)

Creating User Modules
XmlEditList

Learn how to use XmlEditList

Table of contents
1. Initial Considerations
2. XmlFormCollection and ContextValue
3. XmlEditList
4. ProcessPageStateBase

On this page
Using XmlEditList
Creating an XmlEditList
Processing the requests
Personalizing the XmlEditList


Using XmlEditList

EditList is an XMLObject that allows users to build a list of values and select one or more of them to execute a certain action. Internally, the object is paginated.

XmlEditList receives an IIterator as a data source. This way, practically any data repository can be used, whether an AnyDataSet, a DBDataSet, or any other that has been developed by the user.

Image

Creating an XmlEditList

To work with the XmlEditList, a dictionary of data must be provided which specifies which fields in the repository will be visible to the user in the listing.

The basic code to create an XmlEditList will be:

CSharp
XmlEditList editList = 
   new XmlEditList(
      this._context, 
      "Guestbook", 
      "module:sample", 
      true, true, true, true);

PHP
$editList = 
   new XmlEditList(
      $this->_context, 
      "Guestbook", 
      "module:sample", 
      true, true, true, true);

In the example above, module.sample corresponds to the module which will process the request from XMLEditList. The following parameters indicate which buttons will be visible to the user in the following order: NEW, VIEW, EDIT and DELETE.

After the object is created, the data dictionary that the XMLEditList will use needs to be defined. It is very important that the FIRST field be the key field. This field will not be visible on the listing; however, when selecting a register, the value of this field will be submitted to the following page.

CSharp
EditListField field;
			
field = new EditListField(true);
field.fieldData = "frommail"; 
editList.addEditListField(field);
			
field = new EditListField(true);
field.fieldData = "fromname";
field.editlistName = "Nome";
			
field = new EditListField(true);
field.fieldData = "frommail";
field.editlistName = "Email";
editList.addEditListField(field);

CSharp
$field = new EditListField();
$field->fieldData = "frommail"; 
$editList->addEditListField($field);

$field = new EditListField();
$field->fieldData = "fromname";
$field->editlistName = "Nome";
$editList->addEditListField($field);

$field = new EditListField();
$field->fieldData = "frommail";
$field->editlistName = "Email";
$editList->addEditListField($field);

The data source also must be specified. It is fundamental that an Iterator type object be specified for this. See: Data Repository (Any or DB). This data repository should have the fields listed in the repository.

CSharp
editList.setDataSource(it);

PHP
$editList->setDataSource($it);

Processing the requests

Once the XMLEditList is created and added to an XMLBlock Collection, it will be working and the buttons will be submitting information to the page indicated in its builder.

The XmlEditList submits only two pieces of information to the page it will process:

  • ACTION field, which contains the action that was requested by the user. The standard actions are: new, view, delete and edit. To facilitate the process, the BaseModule class created the chamada_action property, which will contain the action selected by the user.
  • VALUEID field, which contains the value of the first field which was defined in the XmlEditList.

CSharp
XmlParagraphCollection para2 = new XmlParagraphCollection();
para2.addXmlnukeObject(new XmlnukeText("Action: ", true, false, false));
para2.addXmlnukeObject(new XmlnukeText(this._action));
para2.addXmlnukeObject(br);
para2.addXmlnukeObject(new XmlnukeText("Value: ", true, false, false));
para2.addXmlnukeObject(new XmlnukeText(this._context.ContextValue("valueid")));
			
if (this._action != "")
{
	block.addXmlnukeObject(para2);
}

PHP
$para2 = new XmlParagraphCollection();
$para2->addXmlnukeObject(new XmlnukeText("Action: ", true, false, false));
$para2->addXmlnukeObject(new XmlnukeText($this->_action));
$para2->addXmlnukeObject($br);
$para2->addXmlnukeObject(new XmlnukeText("Value: ", true, false, false));
$para2->addXmlnukeObject(new XmlnukeText($this->_context->ContextValue("valueid")));
		
if ($this->_action != "")
{
	$block->addXmlnukeObject($para2);
}

Personalizing the XmlEditList

In addition to the standard options, it's possible to add other options to the XmlEditList.

Personalized Buttons

This option is useful when the standard options NEW, EDIT, VIEW and DELETE are not relevant to the user and a personalized button is required.

PHP
CustomButtons cb = new CustomButtons();
cb.action = "acaocustomizada";
cb.enabled = true;
cb.alternateText = "Alternative text for action";
cb.url = this._context.bindModuleUrl("sample") + "&op=3";
cb.icon = "common/editlist/ic_custom.gif";
editList.setCustomButton(0, cb);

PHP
$cb = new CustomButtons();
$cb->action = "acaocustomizada";
$cb->enabled = true;
$cb->alternateText = "Alternative text for action";
$cb->url = $this->_context->bindModuleUrl("sample") . "&op=3";
$cb->icon = "common/editlist/ic_custom.gif";
$editList->setCustomButton($cb);

In the last line, the customized button is added to the position ZERO of the button listing.

Pagination

The EditList also natively implements the pagination of the items listed. So that this option works and the navigation bar is added, the following lines of code must be added:

Image

CSharp
editList.setPageSize(3, 0);
editList.setEnablePage(true);

PHP
$editList->setPageSize(3, 0);
$editList->setEnablePage(true);

The number ZERO on the first line indicates that the EditList should generate the pagination. If a number other than zero is sent as a parameter, the EditList will always go to the indicated page.

CheckBox

The standard send method for EditList is through a RadioButton, which allows only one option to be selected. However, whenever it is necessary to select more than one option, the configuration must be changed to CheckBox.

CSharp
editList.setSelectRecordType(SelectType.CHECKBOX);

PHP
$editList->setSelectRecordType(SelectType::CHECKBOX);

XmlEditList will continue sending only one valueid argument; however, the value will be separated by "_"

Additional parameters for the request

Because XmlEditList only sends the action and the valueid, many times it is necessary to add a parameter to theEditList so that it can post this value together with the standard values.

This way:

CSharp
editList.addParameter("op", "3");

PHP
$editList->addParameter("op", "3");

Previous
XmlFormCollection and ContextValue
Next
ProcessPageStateBase