DHX - Generate XML for defining interfaces with DHTMLX
# dhtmlxAccordion
use DHX;
my $accordion = DHX::Accordion->new;
$accordion->cell(
{
id => "bar",
text => "Bar"
}
);
print $accordion->result;
# dhtmlxChart
use DHX;
my $chart = DHX::Chart->new;
$chart->item(
{
id => "01",
sales => "35",
year => "'07"
}
);
print $chart->result;
# dhtmlxCombo
use DHX;
my $combo = DHX::Combo->new;
$combo->option(
{
value => 1,
text => "Baz"
}
);
print $combo->result;
# dhtmlxDataProcessor
use DHX;
my $dataprocessor = DHX::DataProcessor->new;
$dataprocessor->action(
{
type => "inserted",
sid => 2,
tid => 2
}
);
print $dataprocessor->result;
# dhtmlxDataView
use DHX;
my $dataview = DHX::DataView->new;
$dataview->item(
{
id => 1,
Package => "acx100-source",
Version => "20080210-1.1"
}
);
print $dataview->result;
# dhtmlxForm
use DHX;
my $form = DHX::Form->new;
$form->item(
{
type => "input",
name => "foo",
label => "Foo"
}
);
print $form->result;
# dhtmlxGrid
use DHX;
my $grid = DHX::Grid->new;
$grid->row(
{
id => 1,
cell => [
'Foo',
'Bar',
'Baz'
]
}
);
print $grid->result;
# dhtmlxMenu
use DHX;
my $menu = DHX::Menu->new;
$menu->item(
{
id => "new",
text => "New"
}
);
print $menu->result;
# dhtmlxScheduler
use DHX;
my $scheduler = DHX::Scheduler->new;
$scheduler->event(
{
id => 1,
start_date => "2009-05-24 00:00:00",
end_date => "2009-06-08 00:00:00",
text => "French Open",
details => "Philippe-Chatrier Court Paris, FRA"
}
);
print $scheduler->result;
# dhtmlxTabbar
use DHX;
my $tabbar = DHX::Tabbar->new;
$tabbar->tab(
{
id => "foo",
text => "Foo"
}
);
print $tabbar->result;
# dhtmlxToolbar
use DHX;
my $toolbar = DHX::Toolbar->new;
$toolbar->item(
{
type => "button",
id => "2",
text => "Foo"
}
);
print $toolbar->result;
# dhtmlxTree
use DHX;
my $tree = DHX::Tree->new;
$tree->item(
{
id => "p1",
text => "parent item 1",
select => "1",
item => [
{
id => "c1",
text => "c item 1",
},
{
id => "c2",
text => "c item 2",
}
]
}
);
print $tree->result;
# dhtmlxTreeGrid
use DHX;
my $treegrid = DHX::TreeGrid->new;
$treegrid->row(
{
id => 1,
open => 1,
cell => [
'Bar',
'Baz',
'Foo'
],
userdata => [
'Bar',
'Baz',
'Foo'
]
}
);
print $treegrid->result;
This package can generate XML for defining interfaces with DHTMLX. It can compose the definition of forms by adding item elements defined using a structure of attributes as an hash or array. The package can generate XML from the added form items and return the generated XML as a string.
- new
-
my $form = DHX::Form->new(encoding => value);
Set encoding is optional. Default is utf-8.
- header
-
return content type "application/xml; charset=utf-8"
- Catalyst
-
$c->res->content_type($form->header);
- Dancer
-
content_type $form->header;
- header_cgi
-
return content type "Content-type: application/xml; charset=utf-8\n\n";
print $form->header_cgi;
- result
-
print $form->result(format);
return XML string, ready for output.
If format is 0, than the document is dumped as it was originally parsed.
print $form->result;
If format is 1, libxml2 will add ignorable white spaces, so the nodes content is easier to read. Existing text nodes will not be altered.
print $form->result(1);
If format is 2 (or higher), libxml2 will act as $format == 1 but it add a leading and a trailing line break to each text node.
print $form->result(2);
Lucas Tiago de Moraes <lucastiagodemoraes {at} gmail.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.