I am trying to refactor a classic asp code base. For the most part it is going well. It had lots of code duplication for different language versions of the site, so for 6 languages the site was replicated 5 times.
I have used json language files and have managed to make it all far more dynamic and it works lovely.
What I am trying to do now is make the Language class a global object throughout the application for ease of use.
I have used global.asa but the instructions and tutorials I find are very minimal and don't really carry anything I am understanding properly.
I have 2 files:
global.asa
<!--#include virtual="/Five/Classes/Language.asp"-->
<object runat="server" scope="session" id="Lang" progid="Language">
Lang = New Language
</object>
and test.asp
<%
Lang.LoadLanguageFile("reportAbuse")
%>
<%= Lang.iString("strTitle") %>
what happens though is I receive
Microsoft VBScript runtime error '800a01a8'
Object required: 'Lang'
/Five/0/test.asp, line 2
I cannot, having looked all around here and the web find anything more than:
GLOBAL.ASA:
<object runat="server" scope="session" id="MyAd" progid="MSWC.AdRotator">
</object>
You could reference the object "MyAd" from any page in the ASP application:
SOME .ASP FILE:
<%=MyAd.GetAdvertisement("/banners/adrot.txt")%>
You cannot use VBScript classes as persisted objects in Classic ASP. The example you give is a COM object scoped to the session which is different from using a POCO class in VBScript.
If you want to implement a scoped COM object you would need to build a DLL and implement your class there then expose it to COM registering it where it can then be accessed via Classic ASP. However, you will probably have issues with the data being persisted (see link).
There may be some special-ist requirements for a COM library scoped to a session but I'm not aware of any.
Useful links
Classic ASP Store objects in the session object
Classic asp persist custom classes in session
Related
I have a portlet that is deployed on a page and I need to produce a link that will load a different portlet (which is in a different module) in full-screen mode. I can load the built in Login portlet this way without a problem, but when I try to load any of my custom portlets I get two red error boxes with the message "You do not have the roles required to access this portlet." And I have the permissions - I can access the portlet fine when added to a page - and I'm even testing with an omni-admin account.
The portlet ID that has the .jsp file is 'subscriptionmanagement_WAR_subscriptionmanagementportlet' and the portlet ID I'm trying to load is 'GRPSignupForm_WAR_NY511RMportlet'. The tag is:
<liferay-portlet:renderURL portletName="GRPSignupForm_WAR_NY511RMportlet" var="grpPortlet" windowState="<%= WindowState.MAXIMIZED.toString() %>">
</liferay-portlet:renderURL>
Which produces the URL: http://localhost:8080/group/test/unsubscribe?p_p_id=tripitinerary_WAR_NY511RMportlet&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view
However, as I've mentioned, I have been able to load other portlets in this way. The login portlet for example using the same tag works fine:
<liferay-portlet:renderURL portletName="<%= PortletKeys.LOGIN %>" var="loginURL" windowState="<%= WindowState.MAXIMIZED.toString() %>">
<portlet:param name="mvcRenderCommandName" value="/login/login" />
</liferay-portlet:renderURL>
The obvious difference is that it is passing a specific render command parameter, but otherwise it is the same. It produces the URL:
http://localhost:8080/group/test-1/unsubscribe?p_p_id=com_liferay_login_web_portlet_LoginPortlet&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view&_com_liferay_login_web_portlet_LoginPortlet_mvcRenderCommandName=%2Flogin%2Flogin
For completeness, here is the code for the portlet I'm trying to load. But as I mentioned above, I have tried to load various portlets in this project and all of them produce the permissions error.
#Component(
immediate = true,
property = {
"com.liferay.portlet.display-category=root//NYSDOT//GRP",
"com.liferay.portlet.instanceable=false",
"com.liferay.portlet.header-portlet-css=/css/main.css",
"com.liferay.portlet.footer-portlet-javascript=/js/main.js",
"com.liferay.portlet.css-class-wrapper=grh-signup-form-portlet",
"javax.portlet.display-name=GRP Signup Form",
"javax.portlet.init-param.template-path=/html/",
"javax.portlet.init-param.add-process-action-success-action=false",
"javax.portlet.init-param.config-template=/html/configuration.jsp",
"javax.portlet.init-param.view-template=/html/view.jsp",
"javax.portlet.init-param.edit-template=/html/edit.jsp",
"javax.portlet.name=" + GRPSignupPortletKeys.GRPSIGNUP,
"javax.portlet.resource-bundle=content.Language",
"javax.portlet.security-role-ref=administrator,guest,power-user,user"
},
service = Portlet.class
)
public class GRPSignupPortlet extends GenericPortlet {
...
...
}
So it's obviously possible, as the Login portlet works. I'm sure there is just some small bit of config I'm missing. I've tried to see what is different in the Liferay Login portlet that allows it to work, but haven't found the secret.
Liferay CE 7.3
You need to add the property 'add-default-resource'. In the component add:
"com.liferay.portlet.add-default-resource=true"
From portal.properties: "add-default-resource" set to true will allow those portlets to be dynamically added to any page by any user. This is useful (and necessary) for some portlets that need to be dynamically added to a page, but it can also pose a security risk because it also allows any user to do it.
It's prudent to also add
"com.liferay.portlet.add-default-resource-check-enabled=true",
From portal.properties: Set this property to true to add a security check around this behavior. If set to true, then portlets can only be dynamically added to a page if it contains a proper security token. This security token is automatically passed when using a portlet URL from one portlet to another portlet.
I am using MVC 5 to build an application. In my web.config I have defined a custom section which I will use to display menu to user. It is something like:
<Menus>
<Menu>
<MainMenu Title="Home"></MainMenu>
<SubMenus>
<SubMenu Title="Page1" PageName="home/index" ADGroup="BusinessUsers">
<SubMenu Title="Page2" PageName="home/index2" ADGroup="ITUsers">
</SubMenus>
</Menu>
<Menu>
<MainMenu Title="About Us"></MainMenu>
<SubMenus>
<SubMenu Title="Another Page1" PageName="about/mypage1" ADGroup="BusinessUsers">
<SubMenu Title="Some Other Page" PageName="about/mypage2" ADGroup="OtherUsers">
</SubMenus>
</Menu>
</Menus>
I am using Windows authentication and everyone will have access via AD groups. By default I have denied access to all users using authorization rule in web.config like below:
<authorization><deny users="*"/></authorization>
Is it possible to define authorization rules based on MENU above in Application_Start at runtime? Something like:
Global.Filters.AuthorizeUser("BusinessUsers", "home/index, about/mypage1");
Global.Filters.AuthorizeUser("ITUsers", "home/index2");
What you're doing here isn't a standard way of defining a menu, so there is no standard way of enforcing authorization on it. You will need to implement it yourself.
Somewhere in your code during a request, you will have to loop through each SubMenu and use HttpContext.Current.User.IsInRole("DOMAIN\\GroupName") to test whether the user is in the appropriate group. I can't give you any further direction than that without seeing more of your code.
I'm sure you have your reasons for putting this in web.config, but what I have done in my own projects is define the menu in a partial view and check the roles right in the view:
#if (HttpContext.Current.User.IsInRole("DOMAIN\\GroupName") {
Some menu item
}
If you're worried about being able to update the menu items without recompiling the whole project, then that's still fine since the cshtml files aren't compiled anyway - you can update it on the fly.
We have a Kentico project where we're using Azure Blob Storage for our media storage. When selecting a media file in a page, it stores the URL like this: www.ourhost.net/blobcontainer/kenticosite/media/medialibrary/picture.jpg
We are also using ImageProcessor.org. This only works when the image is requested through the host itself, so we need the media library selector to store the absolute URL like this: /blobcontainer/kenticosite/media/medialibrary/picture.jpg
How can this be done?
Thanks in advance. Nicolas.
I assume you are talking about Media selection form control, is that correct?
In this case the solution is for you to remove the protocol/domain from the absolute URL which is stored by the form control. You can do this by creating Custom macro since you are using Portal engine macros.
The purpose of the macro will simply be to take the absolute URL and make it a relative URL.
Instead of using this:
<img src="{% CurrentDocument["HeaderImage"] #%}" alt="{% CurrentDocument["Title"] #%}" />
You would call it like:
<img src="{% MyMacros.GetRelativeUrl(CurrentDocument["HeaderImage"]) #%}" alt="{% CurrentDocument["Title"] #%}" />
As you can see I'm using "MyMacros" namespace which is a best practise as it will enable you to keep all your macros organized. You can create custom namespaces as per this article
I am running into a Access-Control-Allow-Origin error when I am trying to build an OpenSocial Gadget with IBM Social Business ToolKit for IBM Connections.
I have 3 servers participating in this gadget:
CONNECTIONS: The IBM Connections 4.0 Server that will be hosting the gadget
IBMSBT: A server hosting the Social Business Toolkit scripts and app
JESSE_API: My application server hosting the API that the gadget will be using
The gadget xml is loaded from JESSE_API by CONNECTIONS. The view for the gadget loads scripts and makes calls to JESSE_API. I would like to use the Social Business Toolkit for accessing parts of Connections so the gadget view is also loading those components from IBMSBT.
I am currently just prototyping this - I was able to make this work just using the Connections 4.0 API but would rather use the SBT libraries.
For getting started I just dropped in the "Get My Communities - Main Window" snippet into my gadget's view and included the following scripts:
<script type="text/javascript">
var djConfig = {
parseOnLoad: true
};
</script>
<script src="//IBMSBT/sbt.dojo180/dojo/dojo.js"></script>
<script src="//IBMSBT/sbt.sample.web/library?ver=1.8.0"></script>
Reloading the gadget gives the following error in the console:
XMLHttpRequest cannot load http://IBMSBT/sbt.sample.web/service/proxy/connections/http/CONNECTIONS/communities/service/atom/communities/my?ps=5
Since my gadget was running on the CONNECTIONS server I should not need the proxy. I did not see an immediate way to disable the proxy for this endpoint so I just set a breakpoint in Endpoint.js before line 160 where the following code is executed:
if(this.proxy) {
args.url = this.proxy.rewriteUrl(args.url,this.proxyPath);
}
When the breakpoint hits, I set this.proxy = null which causes the proxy to not be used and the community information to return correctly.
My question is should I be doing this differently or should a way be added to bypass the use of a proxy given the structure I am currently using?
The SDK Proxy does not need to be used in this environment. We've made some changes in this area recently as part of the work to support OAuth. What you need to do is configure the SDK library initialization so it knows it's running in a Gadget context.
Take a look at the acme.social.sample.webapp:
In faces-config.xml you will see an environment for use with OpenSocial
<!-- OpenSocial Environment -->
<managed-bean>
<managed-bean-name>openSocial</managed-bean-name>
<managed-bean-class>com.ibm.sbt.jslibrary.SBTEnvironment</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
<managed-property>
<property-name>endpoints</property-name>
<value>acmeAirOS:acmeAir</value>
</managed-property>
</managed-bean>
The endpoint definition used a gadget endpoint (further down in the faces-config.xml)
<managed-bean>
<managed-bean-name>acmeAirOS</managed-bean-name>
<managed-bean-class>com.ibm.sbt.services.endpoints.GadgetOAuthEndpoint</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>url</property-name>
<value>%{acme.url}</value>
</managed-property>
</managed-bean>
In the gadget xml (or imported html) when loading the library pass a parameter to indicate that the OpenSocial environment should be used
<script type="text/javascript" src="../../library?ver=1.8.0&context=gadget&env=openSocial"></script>
Based on the information from Mark Wallace, I looked a bit closer at what the /library/ endpoint was doing.
I was not able to make it quite work exactly with that code but the following works nicely:
<script data-dojo-config="parseOnLoad:true"
src="//IBMSBT/sbt.dojo180/dojo/dojo.js.uncompressed.js"></script>
<script>
if(typeof _sbt=='undefined' || window._sbt_bridge_compat){
_sbt=0;
dojo.registerModulePath('sbt','http://IBMSBT/sbt/js/sdk/sbt');
dojo.registerModulePath('sbt/_bridge','http://IBMSBT/sbt/js/sdk/_bridges/dojo-amd');
dojo.registerModulePath('sbt/dojo','http://IBMSBT/sbt/js/sdk/dojo');
define('sbt/config',['sbt/Proxy','sbt/_bridge/Transport','sbt/authenticator/Basic','sbt/Endpoint'],function(Proxy,Transport,Basic,Endpoint){
window.sbt = {};
sbt.Properties={
"sbtUrl":"http:\/\/IBMSBT\/sbt\/js\/sdk"
};
sbt.Endpoints={
'connections':new Endpoint({
"baseUrl":"http:\/\/connectionsww.demos.ibm.com",
"transport":new Transport({}),
"authType":"basic",
"authenticator":new Basic({}),
"proxyPath":"connections"})
};
return sbt;
});
}
</script>
The contents of the script tag was basically the output from the /library/ endpoint. The sbt.Endpoints.connections definition originally included a defined proxy attribute which I removed.
I have created a visual web part that combines two other previously created web parts into one nicely styled web part. This is done simply by adding Register tags to the ascx page of the web part, and then adding the web part tags just as I would on a page layout, like so:
WebPart_ParentAssignmentsUserControl.ascx:
<%# Register tagprefix="WebParts" namespace="Microsoft.SharePointLearningKit.WebParts" assembly="Microsoft.SharePointLearningKit, Version=1.3.1.0, Culture=neutral, PublicKeyToken=24e5ae139825747e" %>
<%# Register tagprefix="MyChildrenWebPart" namespace="MLG2010.WebParts.MyChildren.MyChildrenWebPart" assembly="MLG2010.WebParts.MyChildren, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5" %>
<WebParts:AssignmentListWebPart runat="server" ListScope="false" AllowEdit="True" AllowConnect="True" Title="Assignment List Web Part" IsIncluded="True" Dir="Default" SummaryWidth="150px" IsVisible="True" AllowMinimize="True" AllowHide="True" ExportControlledProperties="True" ZoneID="" ID="g_1c528b46_baf2_4cf2_a004_91f84c4f4556" FrameState="Normal" DisplaySummary="True" ExportMode="All" SuppressWebPartChrome="False" DetailLink="" HelpLink="" MissingAssembly="Cannot import this Web Part." PartImageSmall="" AllowRemove="True" ToolTip="Assignment List - Use this web part to keep track of your SharePoint Learning Kit assignments." HelpMode="Modeless" FrameType="Default" AllowZoneChange="True" PartOrder="0" Description="Display the assignments for an instructor or learner." PartImageLarge="" IsIncludedFilter="" __MarkupType="vsattributemarkup" __WebPartId="{1c528b46-baf2-4cf2-a004-91f84c4f4556}" WebPart="true" Height="" Width=""></WebParts:AssignmentListWebPart>
<MyChildrenWebPart:MyChildrenWebPart runat="server" PageSize="5" StudentsSiteURL="/student" PictureLibraryTitle="Students Picture Library" ADChildAttribute="otheripphone" Description="My WebPart" DefaultPictureURL="../../Students Picture Library/DefaultChild.jpg" ShowErrors="True" PictureLibraryUrl="../../Students Picture Library" Title="MyChildrenWebPart" ADEntryPoint="LDAP://dc=redconnect-test" __MarkupType="vsattributemarkup" __WebPartId="{d13a3729-e2b8-4436-ac1b-b75c914a3596}" WebPart="true" __designer:IsClosed="false" id="g_d13a3729_e2b8_4436_ac1b_b75c914a3596"></MyChildrenWebPart:MyChildrenWebPart>
The problem here, is that I need these two web parts to communicate via web part connections. since they are only added here on the aspx, sharepoint does not "know" about them, and thus they do not get a chrome and thus I cannot set up the web part connections in the browser.
Is there a way to set up web part connections on web parts that are added this way? Or maybe if I can just activate the chrome on these web parts?
You can define the connection statically. Note that using this way, you cannot create/modify/delete the connection using the browser.
See:
How to: Declare a Static Connection between Two Web Parts Controls
In the end, I separated the web part into the pieces that could connect normally, and then used styling to make it look as if they were one. I have not found any documentation on the consequences of putting web parts inside other web parts as i attempted.