I have a h:commandLink
:
<h:commandLink value=""
actionListener="#{controller.authenticateAccount}"
style="text-decoration: none;"
target="#{controller.userNameGiven ? '_parent' : '' }">
<img src="../images/Profile/authenticateCPButton.gif" border="0" style="padding-left: 2px;"/>
</h:commandLink>
Now controller.userNameGiven
is a boolean field and is set to true if username given and otherwise set to false. The h:commandLink
is present in a iframe and prior to this the target
was set to _parent
and then if the username is present then it was redirecting to a page in the same parent window but in other case the iframe was rendered in the parent page which is clearly a bug. Now after the target validation the redirected page is opening in that iframe, which is undesirable. What I am doing wrong?
Thanks and regards.
Edit 1:
I have changed the target
to:
target="#{controller.target}"
where:
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
and
if(this.userName != null && this.userName.trim().length()>0) {
target = "_parent";
FacesContext.getCurrentInstance().getExternalContext().redirect("./somepage");
} else {
target = "";
}
But its still not working and the url somepage is opening in the iframe.
Move the logic into a bean method:
public class Controller
{
// ...
public boolean isUserNameGiven () { /* snip */ }
public String getFooTarget()
{
return this.isUserNameGiven() ? "_parent" : "";
}
// ...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.