Blazor component EventCallback set from CSHTML - components

I have a Blazor component in one of my CSHTML pages. The component has an EventCallback property.
I am getting this compile error:
Error CS0428 Cannot convert method group 'FileUploaded' to non-delegate type 'object'. Did you intend to invoke the method?
Everything works if I am in a Blazor Page which has the Blazor Component, but chokes when using the component in the Razorpage

Related

Is it possible to load a Liferay portlet dynamically on a page from a .jsp file?

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.

To render JSF component from java class when we already know client id of that component

As per my code , I have to render jsf component clicking on radio button .so I have ajax event of Type 'click' , and want to add in the listener attribute that it has to render this jsf component. I have the client ID of that jsf component with me. planning to write the method in controller class.So how can I achieve this in java bean side?
any help is appreciable.

What is the bootstrap process of an Angular Application? When app.component.htm loads and display?

I am new to Angular. I am working on a web application using Angular. When I start the project app.component.(ts, html...) and app.module.ts generated.
I am wondering when will the app.component.html will be rendered?
What should I put in app.component.html,
And when should I create an another component, like homepage component?
Will there be any differences between putting homepage in app.component.html and putting homepage in another component.html?
Welcome to Angular
So how bootstrap process works in Angular Application.
The entry point to every Angular Application is the main.ts file which contains this last line.
The platformBrowserDynamic() part of this line of code indicates that we are about to boot Angular in a browser environment.
The bootstrapModule() function bootstrap our root module which is app.module.ts.
AppModule(app.module.ts) is an entry module and also root module for our application.
app.component.ts is an entry component that we specify in app.module.ts.
So what should you keep in app.component.ts
You can consider app.component.ts as a HomeComponent also, but it is good to keep HomeComponent seprately and giving it's reference to app.component.ts.
You should create separate component for each separate page in your application.
Image source: medium.com
app.component.html is root component file. so its content display top. you create another component its will be render with root component. you can implement app routing module and define here application list of url for file. other word app.component.html is master page. and create new component is child page.
<html>
<head>
</head>
<body>
<!-- Content >> -->
<router-outlet></router-outlet>
<!-- Content << -->
/<body>
</html>
app.component.html is the page that will be rendered from your application. All the component's html pages created will be rendered with in app.component.html.
component's html pages will be rendered based on the routes set in app.module.ts.
for eg: if the route for 'home' is set as homeComponent then home.component.html will be rendered inside app.component.html.
To serve this purpose of dynamically loading the required components the app.component.html will have its content as nothing but output of routing module as,
<router-outlet></router-outlet>
reading further through the angular guide will help in understanding these concepts in depth. https://angular.io/

init() method calls on every request

I am using JSF 2.0 and Liferay 6.1
On any kind of request to any Java class my init() is getting called. Even in case of PrimeFaces component calls for its related PrimeFaces Java method. This method should be called only once when my portlet will initialize.
#ManagedBean
#ViewScoped
public class MyMangedBean {
public void init() {
System.out.println("Init method called");
}
}
Please help me to find out possible solution.
EDIT
I found the component behind this cause
In my xhtml file I have
<bridge:inputFile id="MyFileUpload" size="50"
binding="#{myBean.toBeUploadFile}" onchange="{fileSelected(this);}" style="position: absolute;height: 29px;width:107px;opacity:0;filter: alpha(opacity=0);z-index:100;"/>
Whenever I remove its binding attribute. My project works fine. It will not call init() multiple times. But I need this attribute to get my file uploaded.
I have kept xml namespace as
xmlns:bridge="http://portletfaces.org/bridge"
I have also kept dependency for commons-io(version 1.3) and commons-filedownload(1.2.1) in pom.xml
I dont know what else I am missing for this component or what is actual cause behind this.
You should consider using the bridge:inputFile tag that comes with the latest release of Liferay Faces instead of the older obsolete tags that come from portletfaces.org.
There is a nice demo here that uses the bridge:inputFile that you can try on a Liferay tomcat portal instance, and then follow the same pattern that it uses for file upload.
That demo has been tested, it works great, and it is supported by Liferay.
There are many more demos that are tested and working well on Liferay Portal 6.1. You can download the source for them and build them for yourself as shown here. And follow the version scheme here to make sure that you align the correct versions of the Portal, Mojarra, and the Liferay Faces Bridge.
Hope that helps.

Access Method from a usercontrol in ASP.net

I have a usercontrol in my ASP.net page. I have a method ProcessData() in my asp.net page.
How do I access ProcessData() method which is in the aspx page from my usercontrol?
Please help
From your user control, cast this.Page as whatever type your page code behind class is. Then, you should be ale to call the method on that object.

Resources