I hooked the login portlet to customize it's layout/design and it's working fine...
but when the user input is wrong/incorrect (authentication failed) the layout/design of my login hook is becomes like this...
I want to have SAME LAYOUT even if the authentication failed.
How will I achieve this?
Thank you in advance.
Here's my code in my hook of login struts action
public void processAction(
org.apache.struts.action.ActionMapping actionMapping,
org.apache.struts.action.ActionForm actionForm,
PortletConfig portletConfig, ActionRequest actionRequest,
ActionResponse actionResponse) throws Exception {
}
protected boolean isCheckMethodOnProcessAction() {
return _CHECK_METHOD_ON_PROCESS_ACTION;
}
protected void login(ThemeDisplay themeDisplay,
ActionRequest actionRequest, ActionResponse actionResponse)
throws Exception {
}
protected void postProcessAuthFailure(ActionRequest actionRequest,
ActionResponse actionResponse, StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig) throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest
.getAttribute(WebKeys.THEME_DISPLAY);
PortletURL portleturl = PortletURLFactoryUtil.create(actionRequest,
"secondlogin_WAR_triumainportlet", themeDisplay.getPlid(),
PortletRequest.RENDER_PHASE);
portleturl.setParameter("saveLastPath", Boolean.FALSE.toString());
String redirect = ParamUtil.getString(actionRequest, "redirect");
if (Validator.isNotNull(redirect)) {
portleturl.setParameter("redirect", redirect);
}
else{
portleturl.setParameter("loginError", redirect);
}
portleturl.setWindowState(WindowState.MAXIMIZED);
actionResponse.sendRedirect(portleturl.toString());
originalStrutsPortletAction.processAction(originalStrutsPortletAction,
portletConfig, actionRequest, actionResponse);
}
private static final boolean _CHECK_METHOD_ON_PROCESS_ACTION = false;
private static final Log _log = LogFactoryUtil.getLog(Sample.class);
You will need to adapt your styling of the error messages.
If an error occurs, this and another html fragment will get displayed on the response page. They both have the same markup.
<div class="alert alert-error"> Authentification failed. Please try again</div>
So you would need to style those, or even the surrounding wrapper div. As I am not informed about HOW you changed the css, I can not give you any further or more detailed advise.
[EDIT]
After rereading your question:
Maybe I did understand your question wrong. Is it possible, that you are referring to Layout of the Page itself? That would be related to the response rendering with maximized=true. I think you could modify this behaviour by overriding the StrutsAction.
[EDIT2]
According to your edit in the question ;)
Please try this:
portleturl.setWindowState(WindowState.NORMAL);
Related
Let's say I have a domain object Customer. On this object I have an address to an external site.
#PropertyLayout(named = "Link", describedAs = "Clickable link to customer")
public String getLink() {
return "http://www.customer.com";
}
In this case this will be shown as just text on the webpage. How do I create a clickable link in the wicket viewer from this?
There is a third-party extension: https://github.com/kev-m/isis-wicket-url/
This was done by Kevin Meyer, one of our committers.
I've raised https://issues.apache.org/jira/browse/ISIS-1616 to incorporate this into the framework "proper".
Meantime, you can add an action to open the link easily enough
#Action(semantics=SemanticsOf.SAFE)
#MemberOrder(named="link", sequence="1")
public java.net.URL openLink() throws MalformedURLException {
return new java.net.URL(getLink());
}
and just to finish it off, you could add this guard:
public String disableOpenLink() {
if(getLink() == null) { return "no link to open."; }
try {
openLink();
} catch(MalformedURLException ex) {
return "Bad link";
}
return null;
}
I don't think there is out of the box solution in Apache Isis for this.
You will need to roll your own Wicket component for it. For example, annotate this property with custom annotation #ExternalLink and then register a ComponentFactory that creates Wicket ExternalLink component for this property. See https://github.com/isisaddons/isis-wicket-summernote/blob/master/cpt/src/main/java/META-INF/services/org.apache.isis.viewer.wicket.ui.ComponentFactory for example.
I am creating a JIRA plugin that will show custom page as per my need. In this page I am creating a page that will show a JQL search result. I have created a web-item and action related to it in Atlassian-plugin.xml as below.
Atlassian-plugin.xml
<web-item key="search_allissues_link" name="Srarch All Issues" section="custom_links_link/custom_links_section" weight="10">
<label>Search</label>
<link linkId="create_link">/secure/SearchAllIssuesList!hello.jspa</link>
</web-item>
<action
name="com.plugins.jira.customscreensui.action.JQLSearchAction"
alias="SearchAllIssuesList">
<command name="hello" alias="Hello">
<view name="input">templates/all_issues_list.vm</view>
</command>
</action>
This is my Action class
public class JQLSearchAction extends JiraActionSupport{
List<Issue> issueList;
JQLSearchModel jqlSearchModel;
#RequiresXsrfCheck
protected void doValidation() {}
#RequiresXsrfCheck
protected String doExecute() throws Exception
{
jqlSearchModel=new JQLSearchModel();
issueList=jqlSearchModel.getAllIssuesList();
return "input";
}
#RequiresXsrfCheck
protected String doHello() throws Exception
{
jqlSearchModel=new JQLSearchModel();
issueList=jqlSearchModel.getAllIssuesList();
return "input";
}
public List<Issue> getIssueList() {
return issueList;
}
public void setIssueList(List<Issue> issueList) {
this.issueList = issueList;
}
}
But I am getting following exception
java.lang.IllegalArgumentException: No command 'hello' in action
Please suggest me the solution if any.
Changing the access specifier of the command method to public shall fix your problem. public String doHello().
I have not tried this code, but looking at the code that's the only thing comes in my mind.
Thank you,
I want to add some custom code during the login function, in particular i want to redirect the user after login to the previous page.
For example: i'm on page A , i want to download something from this page, but i'm not authorized. Then pops a popup with link to the login page. After successful login i'm back on page A.
For this purpose i want to overwrite the LoginWidged and to set value to"this.DestinationPageUrl" dynamically.
I read about similar issues here and here, but there isn't an example how to overwrite this LoginWidget class.
I create CustomLoginControl.cs file in my project and register as a new custom control, but after rendering it on the page, it didn't work. Login button does not make nothing. I'm not sure what exactly have to do and which of methods have to overwrite.
namespace SitefinityWebApp.UserControls
{
public class CustomLoginControl : Telerik.Sitefinity.Web.UI.PublicControls.LoginWidget
{
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
this.DestinationPageUrl = "http://previousPage.com";
base.Render(writer);
}
}
}
Can you give me an example how to overwrite this class to work properly.
Version: Sitefinity 5.0, Claims-based authentication
I've done something similar but instead of overriding the login control you can subscribe and capture the UnauthorizedAccess event, send the user to your login page with your redirect page as a query string parameter. You'll need to add a Global.asax / Global.asax.cs file to your project, then add this to the Application_Start function:
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Initialized += BootstrapperInitialized;
}
Then add these two functions:
private void BootstrapperInitialized(object sender, ExecutedEventArgs e)
{
if (e.CommandName == "Bootstrapped")
{
EventHub.Subscribe<IUnauthorizedPageAccessEvent>(OnUnauthorizedAccess);
}
}
private void OnUnauthorizedAccess(IUnauthorizedPageAccessEvent unauthorizedEvent)
{
var manager = ConfigManager.GetManager();
string loginPage = manager.GetSection<ProjectConfig>().DefaultSite.FrontEndLoginPageUrl;
var redirectParam = unauthorizedEvent.RedirectUrl.Replace(string.Format("{0}?ReturnUrl=", loginPage), string.Empty);
var escaped = Uri.EscapeDataString(redirectParam);
unauthorizedEvent.HttpContext.Response.Redirect(string.Format("{0}?ReturnUrl={1}", loginPage, escaped));
}
You will also need to set your default front end login page in the settings under Administration -> Settings -> Advanced -> Project -> DefaultSite and the FrontEndLoginPageUrl setting.
This works for me on a 6.3 site, not sure if this is available in Sitefinity 5 or not.
I'm trying to use captcha as it's shown in this example:
http://www.oracle.com/technetwork/developer-tools/jdev/captcha-099103.html
And it works fine in .jspx page or in .jsff page fragment, but I have to place captcha onto the first page of taskflow, and there... it's not updated! /* I mean the button "can't read image" doesn't work */ I have no idea why. Can anybody help?
Actually, I figured out how to do it by myself:
we need captcha image binding in our bean and the resetting method:
private RichImage captchaImage;
public void setCaptchaImage(RichImage captchaImage) {
this.captchaImage = captchaImage;
}
public RichImage getCaptchaImage() {
return captchaImage;
}
public void resetCaptcha(ActionEvent actionEvent) {
captchaImage.setSource("/captchaservlet?rand=" +
String.valueOf(Math.random()));
AdfFacesContext.getCurrentInstance().addPartialTarget(captchaImage.getParent());
}
All, I didn't know how to do was adding parameter to "/captchaservlet"
And now it works fine :)
But the next problem appears: when returning to this page with captcha from the second one in task flow I need to refresh captcha image. Is there any method that is executed on page return or something?
Aaaaaaaaaaaand I found even more elegant solution: one should just set the source of the captcha image to this method using the expression builder:
public String getCaptchaSource() {
return "/captchaservlet?rand=" + String.valueOf(Math.random());
}
The button "Refresh", of course, should be set as a partial trigger for the image, as in the example.
And that's it :)
I used an Action Filter named [NoCache] to disable the access of login page after login by pressing the browser back button. The code is given below.
public class NoCacheAttribute : ActionFilterAttribute
{
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false);
filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
filterContext.HttpContext.Response.Cache.SetNoStore();
base.OnResultExecuting(filterContext);
}
}
Then i referred it in login page as shown below.
[HttpPost]
[NoCache]
public ActionResult Index(Login objLogin)
{
return RedirectToAction("Index", "Blood");
}
But the result was unexpected. Instead of redirecting to Blood/Index action, the control transfered to the url : http://localhost:4506/Account/Login?ReturnUrl=%2fBlood
How can i correct this ?. Thanks.
This probably related with Form Authentication feature. Do you need it? If not, just don't use it.
For more details, please refer to:
How to remove returnurl from url?