I'm using atocompleter in my form with json.
This is the part of my struts.xml
<package name="default" extends="struts-default,json-default">
<action name="jsonSample" class="com.jaisar.jsep.product.web.action.DatabaseJSON" method="getDatabaseJSONData" >
<result type="json"/>
</action>
</package>
My jsp page is :
<%# taglib prefix="s" uri="/struts-tags" %>
<%# taglib prefix="sj" uri="/struts2-jquery-tags"%>
<s:url id="remoteurl" action="jsonSample.action"/>
<sj:select
href="%{remoteurl}"
id="echo"
name="echo"
list="languageList"
emptyOption="true"
headerKey="-1"
headerValue="Please Select a Language"/>
Action class method is :
public class DatabaseJSON extends ActionSupport {
private List<String> languageList;
public String getDatabaseJSONData() {
languageList = new ArrayList<String>();
languageList.add("Java");
languageList.add("PHP");
languageList.add("C#");
return SUCCESS;
}
// Setters and getters for languageList ..
}
But the page doesn't load with the autocompleter. Page shows simply a select box... Any solutions? Plz ... I refered a lot , but i couln't find the silution...
I referred the site http://code.google.com/p/struts2-jquery/wiki/SelectTag#Receive_Entrys_from_a_simple_String_List
Thanks in advance...
I would try putting dataType='json' attribute in the sj:select tag.
You didn't specify the result name in your struts.xml. Try: <result name="success" type="json">
Related
I have implemented two StreamedContent beans to dynamic load a graphic image, following the solution found
here
1) With the first one I display images in a contentFlow (EVERYTHING OK)
<p:contentFlow value="#{imageBean.images}" var="image">
<p:graphicImage value="#{imageStreamer.fileContent}" styleClass="content" cache="false">
<f:param name="index" value="#{image.index}"/>
</p:graphicImage>
</p:contentFlow>
2) With the second one I try to display images using a foreach (or repeat):
<c:forEach items="#{imageBean.images}" var="item" varStatus="varStatus">
<p:graphicImage value="#{imageStreamer.fileContent}" cache="false">
<f:param name="index" value="#{varStatus.index}" />
</p:graphicImage>
</c:forEach>
This doesn't work. The check (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) is always true.
If I change the scope of the Bean to RequestScoped than it works! I'm confused... can someone help me?
Managed bean:
#ManagedBean
#ApplicationScoped
public class ImageStreamer{
public ImageStreamer(){}
public StreamedContent getFileContent(){
List<Link> links = this.getLinkItems();
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
FacesContext fc = FacesContext.getCurrentInstance();
String linkIndex = externalContext.getRequestParameterMap().get("index");
if(fc.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE){
return new DefaultStreamedContent();
}else{
int parsedIndex = Integer.parseInt(linkIndex);
Link ql = links.get(parsedIndex);
return new DefaultStreamedContent(new ByteArrayInputStream(ql.getBytes()), "image/png");
}
}
}
Since you are using primefaces, try using p:repeat
Repeat is an extension to standard repeat component to provide interoperability between JSF implementations and PrimeFaces components.
https://www.primefaces.org/showcase/ui/data/repeat.xhtml
Currently, i'm working on an AJAX-Controller for my finished Extension.
AjaxController.php - Controller
Lager.php - Extension itself - has HTML outputs
the extension Lager.php runs only on the product view page, styled via catalog.xml in base/default/layouts and shows up under the pricebox.
So. The AjaxRequest, which is sent up by another extension which doesn't matters, works fine like the AjaxController too. But there's a problem. In AjaxController.php i've got a command to execute a function in Lager.php. It does, and with firebug i'm able to see, that he got the right response (the HTML output) too, but i think the layout is false. .. The new Html doesn't show up anywhere on the product view.
AjaxController.php (works fine but no HTML output, or no styling.. cause in html output in firebug theres no included css anymore):
<?php
require_once "Mage/Catalog/controllers/ProductController.php";
class Lager_Lager_AjaxController extends Mage_Catalog_ProductController
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
public function refreshAction()
{
$selected = $this->getRequest()->getParam('selected');
if($selected == 'true')
{
$productId = $this->getRequest()->getParam('productid');
if($productId)
{
$block = $this->getLayout()->getBlockSingleton('lager/lager')->runLager($productId); //does html output
}
}
else
{
}
}
}
?>
The config.xml part of the ajax implementation:
<frontend>
<routers>
<lager>
<use>standard</use>
<args>
<module>Lager_Lager</module>
<frontName>lager</frontName>
</args>
</lager>
</routers>
</frontend>
the catalog.xml part of the extension implementation:
<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
<!--
<action method="addReviewSummaryTemplate"><type>default</type><template>review/helper/summary.phtml</template></action>
<action method="addReviewSummaryTemplate"><type>short</type><template>review/helper/summary_short.phtml</template></action>
<action method="addReviewSummaryTemplate"><type>...</type><template>...</template></action>
BEGIN LAGER IMPLEMENTATION -->
<block type="lager/lager" name="lager" template="lager/lager.phtml" /> <!-- Lager Einbindung -->
<lager_ajax_refresh>
<block type="lager/lager" name="lager" output="toHtml" template="lager/lager.phtml" />
</lager_ajax_refresh>
<!-- END -->
<block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml"/>
<block type="core/text_list" name="alert.urls" as="alert_urls" translate="label">
<label>Alert Urls</label>
</block>
<action method="setTierPriceTemplate"><template>catalog/product/view/tierprices.phtml</template></action>
So the Ajax Controller doesn't use the layout configuration of the extension which is implemented in catalog.xml ..
http://www.directupload.net/file/d/3601/h94loqef_png.htm
Ho to hide the Save as "Export to Word" option in SSRS Reports Tool .
Can any one help out how to resolve the issue.
Kalim's link will hide the options for all the reports rather than hiding it for that specific case only.
Here's an article on how to disable certain file types in SSRS Report Viewer
According to the article, add a OnPreRender action to your ReportViewer and link up in code behind.
ASPX Page:
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%# Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server"
OnPreRender="ReportViewer1_PreRender">
</rsweb:ReportViewer>
Code Behind:
protected void ReportViewer1_PreRender(object sender, EventArgs e)
{
DisableUnwantedExportFormat((ReportViewer)sender, "Excel");
DisableUnwantedExportFormat((ReportViewer)sender, "Word");
}
/// <summary>
/// Hidden the special SSRS rendering format in ReportViewer control
/// </summary>
/// <param name="ReportViewerID">The ID of the relevant ReportViewer control</param>
/// <param name="strFormatName">Format Name</param>
public void DisableUnwantedExportFormat(ReportViewer ReportViewerID, string strFormatName)
{
FieldInfo info;
foreach (RenderingExtension extension in ReportViewerID.LocalReport.ListRenderingExtensions())
{
if (extension.Name.Trim().ToUpper() == strFormatName.Trim().ToUpper())
{
info = extension.GetType().GetField("m_isVisible", BindingFlags.Instance | BindingFlags.NonPublic);
info.SetValue(extension, false);
}
}
}
Two colleagues of mine recently wrote a an article on our companies blog demonstrating exactly how to do this.
Here is the link: http://72.249.186.215/howto/wordpress/sample-page/edit-ssrs-render-format-list/
Feedback on the article would be greatly appreciated.
Let me know if this answers your question or if you need any clarity in the steps given in the article.
If you would like me to post the steps here then I can do that as well.
Hi I have this piece of code:
#{ var canUpdatePaymentStatus = !(User.GetId() == paymentDto.SubmittedByPersonId); }
<input type="checkbox" #(canUpdatePaymentStatus != true ? "title=\"Submitter can not approve\"" : string.Empty) />
What I'm trying to achieve is if canUpdatePaymentStatus is false set the title attribute to "Submitter can not approve".
Hoever this is not working the markup generated is:
<input type="checkbox" title=""Submitter" can="" not="" approve">
so on hover "Submitter is shown.
Does anyone know what I'm doing wrong and how to get the full sentence to appear?
I prefer to use inline. try taking title out of the conditional
<input type="checkbox" title="#(canUpdatePaymentStatus != true ? "Submitter can not approve" : string.Empty)" />
This is more verbose but should work:
#{
var canUpdatePaymentStatus = !(User.GetId() == paymentDto.SubmittedByPersonId);
}
#if (!canUpdatePaymentStatus) {
<input type="checkbox" title="Submitter can not approve" />
} else {
<input type="checkbox" />
}
You can handle this neatly with an extension method:
using System.Web.Mvc;
using System.Web.Mvc.Html;
namespace YourProjectName.Helpers
{
public static class CheckboxExtensions
{
public static MvcHtmlString CheckBoxPaymentStatus(this HtmlHelper helper,
string name, bool canUpdatePaymentStatus)
{
if (!canUpdatePaymentStatus)
return helper.CheckBox(name, new { title = Status });
return helper.CheckBox(name);
}
private static string Status = "Submitter can not approve";
}
}
To make the helper available to your view, you'd need to modify your ~/Views/Web.config (make sure it's that one and not the one in the root folder of your project) to add the namespace. In the <system.web.webPages.razor> tag you'll find a list of namespaces. You want to add the helper one to that. So it might look something like this:
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="YourProjectName.Helpers" />
</namespaces>
Then in your view:
#Html.CheckBoxPaymentStatus("PaymentStatus",
!(User.GetId() == paymentDto.SubmittedByPersonId))
You could even modify the helper to take a message as a parameter if you wanted, for extra flexibility.
However, what would be better is to add a bool property to your view model called CanUpdatePaymentStatus and set that in the controller:
public ActionResult SomeAction()
{
YourPaymentViewModel model = // ...
model.CanUpdatePaymentStatus = !(User.GetId() == model.SubmittedByPersonId);
return View(model);
}
Then in the view you can simplify things to:
#Html.CheckBoxPaymentStatus("PaymentStatus", #Model.CanUpdatePaymentStatus)
So I've been working hard for a while to build a solution which creates certain components using nothing but Castle DynamicProxy (version 2.2) and an interceptor. Everything looks great except that at the end of all this I realized I need to register these components with the windsor container. Is this possible or has my work been for naught?
I'll fabricate 2 castle configurations to explain my problem. The first one works, while the second does not.
First config (this has been working great for a while):
<castle>
<facilities>
<facility
id="factory.support"
type="Castle.Facilities.FactorySupport.FactorySupportFacility, Castle.MicroKernel" />
</facilities>
<components>
<component
id="Factory"
service="Foo.IFactory, Foo"
type="Foo.Local.LocalFactory, Foo.Local" />
<component
id="Loader"
service="Foo.Contracts.ILoader, Foo.Contracts"
type="Foo.Local.Loader, Foo.Local"
factoryId="Factory" factoryCreate="GetLoader" />
</components>
</castle>
Second config (I don't know what to put in the type attribute and it doesn't work without it):
<castle>
<facilities>
<facility
id="factory.support"
type="Castle.Facilities.FactorySupport.FactorySupportFacility, Castle.MicroKernel" />
</facilities>
<components>
<component
id="Factory"
service="Foo.IFactory, Foo"
type="Foo.Remote.RemoteFactory, Foo.Remote" />
<component
id="Loader"
service="Foo.Contracts.ILoader, Foo.Contracts"
type="I DUNNO, WHAT'S THE TYPE?"
factoryId="Factory" factoryCreate="GetLoader" />
</components>
</castle>
So my fabricated configs register the factory facility, then I register a factory, then register my "ILoader" component. The "LocalFactory" creates an actual type for the ILoader component, whereas the "RemoteFactory" creates the ILoader component using dynamic proxy, creating the proxies without targets. I.e., I use the ProxyGenerator.CreateInterfaceProxyWithoutTarget method, so there is no underlying class.
So, is there any hope in registering components as per the second config?
EDIT:
Unfortunately, using the fluent configuration API is not an option at the moment. So to narrow my question down, is it possible to achieve this using the XML configuration?
I believe this is possible via the Fluent Registration API and the "UsingFactoryMethod" mechanism. I have tried to replicate your fabricated scenario in the below test case.
UPDATE
This is in fact possible with XML configuration as well. The trick is just to list the interface itself as the "type" in the configuration (or, equivalently, only specify the "type", as the "service" will be set to the "type" if it is not explicitly provided). I have updated the test case below to include a "TestXml" test that uses xml configuration to achieve your desired result. The "TestFluent" test uses the fluent registration API to achieve it. FYI, I am using Castle Windsor 2.0 here, as I'm guessing that's what you're using.
using Castle.DynamicProxy;
using Castle.Facilities.FactorySupport;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using NUnit.Framework;
namespace CastleTests
{
public interface ILoader
{
void Load();
}
public interface ILoaderFactory
{
ILoader GetLoader();
}
public class LoaderFactory : ILoaderFactory
{
public ILoader GetLoader()
{
return GetLoaderStatic();
}
public static ILoader GetLoaderStatic()
{
return (ILoader) new ProxyGenerator().CreateInterfaceProxyWithoutTarget(typeof (ILoader));
}
}
[TestFixture]
public class DynamicFactoryTests
{
[Test]
public void TestFluent()
{
using (var container = new WindsorContainer())
{
container.AddFacility<FactorySupportFacility>();
container.Register(
Component.For<ILoader>().UsingFactoryMethod(() => LoaderFactory.GetLoaderStatic())
);
var loader = container.Resolve<ILoader>();
Assert.That(loader.GetType().FullName, Is.EqualTo("Castle.Proxies.ILoaderProxy"));
}
}
[Test]
public void TestXml()
{
using (var container = new WindsorContainer("factory.xml"))
{
var loader = container.Resolve<ILoader>();
Assert.That(loader.GetType().FullName, Is.EqualTo("Castle.Proxies.ILoaderProxy"));
}
}
}
}
The content of "factory.xml" is thusly:
<castle>
<facilities>
<facility
id="factory.support"
type="Castle.Facilities.FactorySupport.FactorySupportFacility, Castle.MicroKernel" />
</facilities>
<components>
<component
id="foo"
service="CastleTests.ILoaderFactory, CastleTests"
type="CastleTests.LoaderFactory, CastleTests" />
<component
id="bar"
type="CastleTests.ILoader, CastleTests"
factoryId="foo" factoryCreate="GetLoader" />
</components>
</castle>