CWidget able to both begin/end and just widget init

On CWigdet again there are 2 occassions the one that is like $this->widget()… that the user must pass a dataProvider to work… the second occassion is the user will use beginWidget and endWidget and what html code is between this 2 calls will be affected by the widget. The question is how can i create a div at the beginWidget and close the div at the endwidget. And 2nd how can i determine what user used to init the widget.

Examples:

1st occassion:


$this->widget('Mywidegt', array('data'=>$dataProvider));

result in


<div id='mywidget'>

<ul>

 <li>model1</li>

 <li>model4</li>

 <li>model3</li>

 <li>model2</li>

</ul>



then i want in the second occassion like:


<?php

$this->beginWidget('Mywidget');

?>

<ul>

<li>Test1</li>

<li>Test2</li>

</ul>

<?php

$this->endWidget();

?>

have this result:




<div id='mywidget'>


<ul>

<li>Test1</li>

<li>Test2</li>

</ul>

</div>



Off course i can dig to existing widget sources. But though someone out there can be clear and helpfull.

And what i said before. How in mywidget code can i determine which from the above 2 occassions i am running on.