How to access values from dynaaction form in jsp - struts

I can set the attributes in the servlet and I can get those values in jsp by accessing the get attribute.
do we have anything to access values in jsp like that.
For Example:
DynaActionForm home = (DynaActionForm) form;
String age = (String)home.get("age");
I want to access this age in jsp.
Please help me solve this.
Thanks

If your struts-config.xml file is configured correctly, all you need to do is use the bean:write tag.

You can add the map of your formbean in the request scope like that:
Map m = dynaform.getMap();
request.setAttribute("mapForm", m);
And then access propertys into your jsp with:
${mapForm['nameOfYourFormProperty'] }
This is using JSTL. Otherwise you can use that:
<%= ((Map)request.getAttribute("mapForm")).get("nameOfYourFormProperty") %>

Are you asking if you can access DynaActionForm values directly within the Struts View (jsp) component?
You could try setting the DynaActionForm as a request attribute in your Struts Action:
DynaActionForm myForm = (DynaActionForm) form;
request.setAttribute("myForm", myForm);
Then in your JSP page import DynaActionForm and do something like:
DynaActionForm myForm = (DynaActionForm) request.getAttribute("myForm");
String age = (String) myForm.get("var");
But it would be much better to just access the value you needed within the Struts Action and just set that value onto the request or session.

Related

how to set meta tag dynamic from database in mvc

ViewData["ChildPageMetaConent"] = lstPageMetaContentChilds; // from this line i get data from database and set to ViewData .
Example : in ViewData["ChildPageMetaConent"] have list class. You can check in Image.
And on Master.cshtml I am accessing ViewData["ChildPageMetaConent"] variable and gointo to write on
page but its print on page like a text .
And on HTMl its look like this :
I got the Answer.
Need to Use #Html.Raw(string)
so it print exact html tag on page.

Navigate to new Page in Codebehind using NavigationService

I want to access my page to setup the XAML Page:
Dim Pg As New PageListPickerSelection
Pg.StartCalculating(199,"Z-UU", MyCalculationDataIEnumList, myImageSource)
App.NavigationService.Navigate(New Uri("/uc/ListPicker/PageListPickerSelection.xaml", UriKind.Relative))
But NavigationService.Navigate does not support Objects or referenced pages.
How is the correct procedure to show the own page?
Or asked in another way: How does the "ListPicker in the WP7" solve this when showing his separated page?
Regards
If I understand your question, you are asking how to configure a page before navigating to it, correct?
The navigation service will create your pages as you navigate to them on the fly. It is not possible to give the navigation service the page as an object If you need to pass data into a page you can use the normal method of appending params to a URI as such (using c# as I am not familiar with VB):
NavigationService.Navigate(new Uri("/uc/ListPicker/PageListPickerSelection.xaml?Param1=" + (199).ToString() + "&Parm2=" + "Z-UU", UriKind.Relative));
Later in the PageListPickerSelection's OnNavigatedTo() method you can parse the parameters again as such:
string p1 = this.NavigationContext.QueryString["Param1"];
string p2 = this.NavigationContext.QueryString["Param2"];
You could use a static class in which you have a couple of static values which you write when leaving the first page and read when opening the second page.
If you don't like static classes / variables you could use a singleton.

Yii Retrieve and store in a variable a renderPartial file

I have a php file under protected/views/directory_controller_name with formatting like that
<p>
<?php echo $model->title;?>
</p>
...
I display the file with classic method in the controller :
$this->render('filename',array('model'=>$model));
But know, I need to send an email with the same template/layout so I want to store the render of the file in an variable like
$msgHTML = $this->renderInternal('_items', array('model'=>$model));
But it doesn't work!
How can I get render view from a file and store in a variable?
Is it possible?
I don't want to use:
$msgHTML = '<p>'.$model->title.'</p>'
...
Because the file is very long and I don't want to duplicate code!!!
Don't use the renderInternal method, use renderPartial instead. Render internal is low level method and should not be used in such context. To catch the output just set the $return parameter to true:
<?php $output = $this->renderPartial('_subView', $dataArray, true); ?>
$msgHTML = $this->renderInternal('_items', array('model'=>$model), true);
http://www.yiiframework.com/doc/api/1.1/CBaseController#renderInternal-detail
I might be missing something, but can't you just use regular render() with the return argument set to true? Then you can just use a view 'name' instead of knowing the path. (And unless my trusty stack trace logger is broken, renderFile and renderInternal take the same fully qualified path argument. At least I can see renderPartial() passing the full path to my view file to renderFile.)
you can do this with these ways
1) if you want to get the output with header and footer (i.e ) full layout then do this
//add true in the last parameter if you want a return of the output
$htmloutput=$this->render('_pdfoutput',array('data'=>'nothing'),true);
2) similarly if you don't want to get the layout files just use renderpartial in the same way
$htmloutput=$this->renderpartial('_pdfoutput',array('data'=>'nothing'),true);
you will get the html of files in the variable . use this anywhere

Setting datepicker element in Zend_config_Ini

I am trying to create form element using Zend_Config_Ini. Among other elements, I have a datepicker element (zendx_jquery_form_element_datepicker) which fails to work.
I have tried setting the element like so:
user.login.elements.Date.type = "datePicker"
and
user.login.elements.Date.type = "zendx_jquery_form_element_datepicker"
either way ends in the same error message:
Plugin by name 'Zendx_jquery_form_element_datepicker' was not found in the registry; used paths: Zend_Form_Element_: Zend/Form/Element/
or
Plugin by name 'DatePicker' was not found in the registry; used paths: Zend_Form_Element_: Zend/Form/Element/
Please help, thanks.
Just add prefix path before form config
$form = new Zend_Form();
$form->addPrefixPath('ZendX_JQuery_Form_Element', 'ZendX/JQuery/Form/Element', 'element');
$form->setConfig($config->form);
Try
user.login.elements.Date.type = "DatePicker"
The class name is class
ZendX_JQuery_Form_Element_DatePicker
I dont know how to make form using ini file. But I know Zendx_jquery_form_element_datepicker is not standed zend form element. It is make by ZendX. So you cant use it as zend element.

Magento - Get variable from grid to admin controller

My question is about,
how to get a variable from a Magemto grid to My admin controller page.
(ie Exactly to my public function massStatusAction())
Thanks.
You can get those ID like this
$productIds = (array)$this->getRequest()->getParam('product');
Where product is set as Mass Action field in the Grid's protected function _prepareMassaction() like this.
$this->setMassactionIdField('entity_id')
Hope this helps!