I have PortletA and PortletB. Both are java portlets and after I click a button in PortletA, I need to render PortletB(render PortletB in the sense I need to make it as request target, i.e isRequestTargetted must be true) .
Please let me know, how to do it from the processAction method with an example.
processAction(ActionRequest req, ActionResponse res)
Sounds like you need some basic portlet communication, either through an event or a public render parameter. I've only used WebSphere Portal do these, so I don't feel confident guiding you through a WebLogic example, but a quick Google search gave me this documentation that you can read through. I imagine it should provide you with what you need.
http://docs.oracle.com/cd/E13218_01/wlp/docs81/ipcguide/index.html
Related
I have a custom webpart that is inside a Portal Page template. It needs to call an async web api method on a button click.
I know for an ASPX based template we would see the Page property like:
<%# Page Title="" Language="C#" ...... Async="true" %>
But I'm not sure if this is accessible using portal template.
If it's not possible and I have to create an ASPX template - is it possible for it to reference a portal based masterPage or would I have to pull that out into an aspx page too?
The reason I need this property set is support this code:
protected void btnProcessPayment_Click(object sender, EventArgs e)
{
Page.RegisterAsyncTask(new PageAsyncTask(ExecuteValidation));
}
private async Task ExecuteValidation()
{
I have found this to be a reliable implementation in web forms.
Although I am not sure that you can set a whole page as Async, there are other options here.
You could use Kentico's AsyncControl - this control is used throughout the admin interface for asynchronous processing
You could use Kentico's AsyncWorker - if for some reason you cannot
use the AsyncControl this can be a valid alternative
Async does not really stick well with whole webforms life cycle for controlls and callbacks can break the cycle, for example if a page is loaded. Running worker thread or AJAX calls are usually better option. Even AsyncControl is attaching to a thread at some point and leveraging it to do the job and changing its rendering based on that.
It could work as long as there are no other complex controls on the page. MVC will really help here, but that is beyond Kentico 11 and portal at this point.
How do you use redirection on Acumatica mobile xml or msdl to redirect to an external link?
All I could find is If an action on an Acumatica ERP form provides redirection to an external URL, you can map the action to use it in the mobile app. To do this, you need no additional attributes in the action object. However, the redirect attribute of the tag must be set to True, as shown in the following example.
Thanks
There may be other ways, but from the new T410 course for MSDL in 2018R2, you need to do a couple of steps. (Got this at Acumatica Summit 2018 Web Services course - Lesson 6 in the training guide which should be available soon if not already.)
First, define a new toolbar button on the form for your external link
(This example is for the SO303000 screen)
public PXAction<AR.ARInvoice> TestURL;
[PXButton(CommitChanges=true)]
[PXUIField(DisplayName = "TestURL")]
protected void testURL(){
throw new PXRedirectToUrlException(
"http://www.acumatica.com",
"Redirect:http://www.acumatica.com"
)
}
After publishing your project, go back to the Customization Project in the Mobile Application section to map the button. Add this to the commands section of the page as shown in the following example.
add container "InvoiceSummary" {
add field …
add recordAction "TestURL" {
behavior = Void
redirect = True
}
}
Not sure if this answered your question as you pretty much had the MSDL code listed, so maybe it is a matter of where you placed your code within the mobile definition? In the training class, we placed it inside the container where we wanted the link which then appears on the menu on the mobile app when viewing that container.
I have a simple method accepting PortletResponse and PortletRequest in my liferay portlet
public void remove(PortletResponse response, PortletRequest request) {
}
I want to set response status to 404, like I can do with HttpServletResponse by httpResponse.sendError(HttpServletResponse.SC_BAD_REQUEST)
Can you tell me how I can do it?
What does Portlet Specification 2.0 have to say - you can set the response status only when handling resource request:
If the portlet want to set a response status code it should do this
via setProperty with the key ResourceResponse.HTTP_STATUS_CODE.
That means, you can set the response status code this way when serving resources:
resourceResponse.setProperty(ResourceResponse.HTTP_STATUS_CODE,
Integer.toString(HttpServletResponse.SC_BAD_REQUEST));
With Liferay, you can get instance of the underlying HttpServletResponse and set status code there. The portal will return it to the client. This way, you can set the response status for any portal request, not only resource request.
HttpServletResponse httpServletResponse = PortalUtil.getHttpServletResponse(portletResponse);
httpServletResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST);
However, such practice is strongly discouraged as well explained in Olaf Kock's answer. See it to get the bigger picture.
In addition to Tomas Pinos' answer (please accept his answer): Note that a portlet is never delivered directly by an HttpServletRequest - it's embedded in a page which is generated by the portal. Thus the HTTP response codes don't have any meaning (for portlets) in the portal world: The page might still be there, just contain or not contain the portlet in question - it's the business of the portal to show whatever it likes then.
The only exception to this rule is what Tomas describes correctly: When handling a resource request, you're serving exclusive content - thus you have the option to do more to the request than just piping HTML that would otherwise be embedded in a page generated by someone else (the portal, together with other unknown portlets)
i've got a security question and i don't know, how to do this in JSF.
In PHP i can react on a form submit that is defined as POST, that i only want values via POST so there is no way to get an value via GET from the same name of the field.
Example:
fieldname in form: username
in my PHP site i can get the value via $_POST["username"] but not with $_GET["username"], because i don't implement the GET way, only POST.
So, now i want this in my JSF site too.
The problem is, that i can't only implement POST for all requests, i must react on GET also.
I only want, that my form data will come via POST to my bean and not via GET.
How can i reach this?
With a filter or something else?
For your interest: i'm not able to use JavaScript in my application.
Thanks a lot!
I'm not sure I understood your question but if you just need to check if a method on your backing bean was invoked using POST or GET you can get that information from the HttpServletRequest object like so :
#ManagedBean(name="myBean")
#ViewScoped
public class MyMBean implements Serializable{
public void handleForm(){
HttpServletRequest req = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
if(req.getMethod().equalsIgnoreCase("POST")){
//Handle your form data
}
}
Just check FacesContext#isPostback().
if (FacesContext.getCurrentInstance().isPostback()) {
// It's a JSF POST request.
}
I have a simple HTML page which contains a form (uses GET method), whose action is a portal page containing a JSF portlet. I need to access the parameters passed in to the portal page in my portlet - how can I achieve this?
I have tried to access the parameter code on the view page using following code but the value comes up as null.
java.util.Map requestMap = javax.faces.context.FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
String code = requestMap.get("code");
At some other forum it was suggested that I need to pass the the portlet id as request parameter in order to have the portlet access to passed request parameters. If that is true where/how can I lookup my portlet ID so that portlet has access to request parameters?
I would look into whether the WebSphere implementation of public render parameters supports this. If the ExternalContext request parameter map does not expose these values, you can cast the request to a PortletRequest and make use of the Map<String,String[]> getPublicParameterMap() method.
See my article Passing query parameters to JSR-286 portlets here.
I know this is a supported way to do it. I have seen other articles that claim you can simply cast the PortletRequest to something and get the parameters. This is probably not supported in that it depends on a particular implementation and reference to an internal class name. I recommend the above.