Seam page navigation with includes - jsf

I'm using seam page navigation rules. and did not experience any problem with adding rules which redirect from one page to another.
But since I designed my page views using those redirection simply don't happen anymore for those pages.
Tried to define the rule to the view that gets included, then to the view that includes the others (which to me was making more sense) but none work.
Is there anything special about page navigation in seam using included view-id ?
main.xhtml:
<h:outputLabel value="Details:"/>`
<a4j:include viewId="contacts.xhtml" id="contactsDetails"/>`
<page view-id="/*" login-required="true">
<navigation>
<rule if="#{myBean.readyToSee}">
<redirect view-id="/see-contat.xhtml"/>
</rule>
</navigation>
</page>
I'm using jsf, xhtml as my page views.
Thanks

Its difficult for me to answer this question because I simply don't understand it. However I will try to guess what you are asking.
You have a page ie: /somePage.xhtml and inside that page you include some other pages.
I tend to write all my page navigation in pages.xml. I like having everything in one place, because it makes things cleaner and easier to maintain.
You can use wildcards also in the pages.xml file.
So you can do something like this.
<page login-required="true" view-id="/admin/*">
<restrict>#{s:hasRole('orgadmin') or s:hasRole('sysadmin')}</restrict>
<navigation from-action="#{userAdmin.editUser}">
<redirect view-id="/admin/create_user.xhtml" />
</navigation>
<navigation from-action="#{applicationProcessAdmin.saveScheme}">
<rule if-outcome="failure">
<redirect view-id="/admin/processes.xhtml" />
</rule>
</navigation>
</page>
In the above example, I am using a wildcard to say that all navigation that happens from /admin/* that uses some specific action, should redirect to some page i have.
You can also be very specific with the pages
<page login-required="true" view-id="/officer/admin/contacts.xhtml">
<begin-conversation join="true" />
<navigation from-action="#{officerAdmin.saveContact}">
<redirect/>
</navigation>
</page>
If this doesn't help you, you need to clarify your question better.
Update
Try changing your
<page view-id="/*" login-required="true">
<navigation>
<rule if="#{myBean.readyToSee}">
<redirect view-id="/see-contat.xhtml"/>
</rule>
</navigation>
</page>
To this instead
<page view-id="/*" login-required="true">
<navigation from-action="#{myBean.readyToSee}">
<rule if="#{myBean.readyToSee}">
<redirect view-id="/see-contat.xhtml"/>
</rule>
</navigation>
</page>
UPDATE 2
Does all your navigation fail? Or is it only some?
Try removing the /* on page view and replace with just *
If you do this will work:
#Name("myBean")
public class MyBean {
public String doSomething() {
return "success";
}
}
Now from your xhtml (Does not matter which include page it is from)
<!-- Depending on what button you are using, <h:form> is mandatory -->
<h:form>
<h:commandButton value="TEST" action="#{myBean.doSomething}" />
</h:form>
And in your pages xml
<page view-id="*">
<navigation from-action="#{myBean.doSomething}">
<rule if-outcome="success">
<redirect view-id="/test.xhtml" />
</rule>
</navigation>
</page>
The above will work. If it does not, the error is somewhere else in your code.

Related

IIS URL Rewrite with ColdFusion keeps duplicates string

I have set up a URL rewrite which works fine when I manually set or type in the URL. But when I use a link in the page within a <cfoutput> tag for example, the link duplicates the string.
I'm using ColdFusion 2016 with IIS 10
For example the URL is
www.site.com/results.cfm?lang=1&categoryid=2&budegtid=all&typeid=all&propertyid=316
and I want it outputted like
www.site.com/properties/en/all/all/all/316
it works but what seems to be happing when I set the link using...
<cfoutput> using the query...
<cfif getProps.recordcount>
<cfoutput query = "getProps" startrow="#url.start#" maxrows="#perpage#">
View
</cfoutput>
the result in the link on the page outputs as www.site.com/properties/en/all/all/all/316/properties/en/all/all/all/316
I have web/config set up as
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
<rewrite>
<rules>
<rule name="Property list URL rewrite">
<match url="^property/([_0-9a-z-]+)/([_0-9a-z-]+)/budget-range-([_0-9a-z-]+)/([_0-9a-z-]+)/([_0-9a-z-]+)" />
<action type="Rewrite" url="resultsproperty.cfm?lang={R:1}&categoryid={R:2}&budegtid={R:3}&typeid={R:4}&propertyid={R:5}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
<httpErrors errorMode="Detailed" />
</system.webServer>
</configuration>
The ColdFusion cfquery is as follows...
<cfquery name="getProps" datasource="#session.odbcname#">
SELECT *
FROM properties P
INNER JOIN areas A
ON A.area_id = P.property_areaid
INNER JOIN categories C
ON C.category_id = P.property_propcategoryid
INNER JOIN price R
ON R.price_id = P.property_regularity
INNER JOIN types T
ON T.type_id = P.property_proptypeid
WHERE P.property_status != 'Off Market'
<cfif url.ref is not "all">
AND
(
property_ref like <cfqueryparam cfsqltype="cf_sql_varchar" value="%#url.ref#%">
OR property_refid like <cfqueryparam cfsqltype="cf_sql_varchar" value="%#url.ref#%">
OR property_town like <cfqueryparam cfsqltype="cf_sql_varchar" value="%#url.ref#%">
)
</cfif>
ORDER BY P.property_refid
It seems to be pulling in the actual URL first and then adding on the rewrite.
Any help much appreciated.
You need to start the href with a forward slash to indicate it is from root. The href is resolved/interpretted in the browser. Not starting with a forward slash tells the browser that the url is relative to the current path.
If you are at http://example.com/admin/ and have an href logout for example it will be resolved as http://example.com/admin/logout. However if you have an href /logout it will resolve to 'http://example.com/logout.
As your own answer stated, forcing an absolute path works and can be preferred sometimes but sometimes not. Make sure you understand the underlying issue.
Solved! by pre setting the URL root in the coldfusion application file i.e. <cfset request.root = 'http://www.example.com/'> and then reference the #request.root# var within the link, it uses the link correctly and dose not duplicate the url. So this is a cold fusion issue rather than a URL ReWrite issue.

URL rewrite for JSF

I'm using JSF, Jboss. I used urlrewrite filter and i don't know why:
when i type localhost:8080/myweb/user/myname will be forwarded to localhost:8080/myweb/user.xhtml?u=myname. it makes me don't like urlrewritefilter.
After that, i try using prettyfaces. Maybe, it is good for others, not me. i can't find out good tutorials except the documentation. ajax error after adding prettyfaces into my project. And some codes in pretty-config.xml
<url-mapping id="ideas">
<pattern value="/article/#{g}" />
<view-id value="/ideas/article.xhtml" />
</url-mapping> -->
And a form in jsf page will redirect this page with param
public String addUserToGroup() {
...
return "/ideas/article.xhtml?g=" + g + "&faces-redirect=true";
}
can't run.
Can you give me some advices about what library i should use to rewrite URL now. Or how to fix errors of prettyfaces. thanks
Is your configuration commented out? I noticed the '-->' in your code snippit.
<url-mapping id="ideas">
<pattern value="/article/#{g}" />
<view-id value="/ideas/article.xhtml" />
</url-mapping> -->

Joomla 2.5 ACL restrict to specific features/views

I seem to be having a problem identifying how to restrict Joomla 2.5 back-end users to specific features / Views in a custom component I am writing. According to my understanding I should be able to add my views as a section in the access.xml file. I have attempted this by naming a section the same name as my view but I don't seem to be able to change the access to that view independently from the component as a whole. Does anybody have a more in depth example I can review or tips? Is this even possible?
I believe what you are trying to do is not supported by Joomla.
My suggestion is to add a custom rule for views in access.xml
<section name="component">
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />
<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" />
<action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" />
<action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" />
<action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" />
<action name="core.edit.state" title="JACTION_EDITSTATE" description="COM_CATEGORIES_ACCESS_EDITSTATE_DESC" />
</section>
<section name="views">
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />
</section>
Then save your view in the #__assets table with a name like com_component.view.playerlist,
in the rules field you should save a JSON encoded list of your rules:
{"core.admin":{}}
You can check if current user can or cannot access a determinate section using JAccess
$user_id=JFactory::getUser()->id;
$has_permission = JAccess::check($user_id,'core.admin','com_component.view.playerlist');
if($has_permission){
draw_view();
}else{
JError::riseError(403,JText::_('PERMISSION_DENIED'));
// or
JError::raiseWarning(403,JText::_('PERMISSION_DENIED'));
}
If you have any doubt, feel free to comment.

Syntax within a Seam page.xml to output current date?

Is it possible to something like the following to assign the 'occurredAt' attribute with a call using Seam's extended support for SEAM EL (seam 2.2)?
<navigation>
<rule if-outcome="search">
<out name="occurredAt" scope="event" value="#{new java.util.Date()}"/>
<redirect view-id="/ui/search.xhtml"/>
</rule>
</navigation>
seam has built-in #{currentDate} factory method, so you can write;
<navigation>
<rule if-outcome="search">
<redirect view-id="/ui/search.xhtml">
<param name="occurredAt" value="#{currentDate}"/>
</redirect>
</rule>
</navigation>
and you can access occuredAt parameter from search.xhtml

Home page to be rendered according to user type

I use the following code to redirect to my home page on login... now i want to go a step further and add a logic where it redirects to different page based on user type.
for eg: if a user type is employee then i should redirect to employeehome.xhtml and so on ... is this possible ?
<page xmlns="http://jboss.com/products/seam/pages"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.2.xsd">
<navigation from-action="#{identity.login}">
<rule if="#{identity.loggedIn}">
<redirect view-id="/Home.xhtml" />
</rule>
</navigation>
I suppose you have a login.xhtml page from which the user logs in.
Then you can create a login.page.xml page containing some navigation rules. For example:
<navigation from-action='#{identity.login}'>
<rule if="#{identity.loggedIn and s:hasRole('management')}">
<redirect view-id="/management/home.xhtml"/>
</rule>
<rule if="#{identity.loggedIn and s:hasRole('upload')}">
<redirect view-id="/secure/upload.xhtml"/>
</rule>
<rule if="#{identity.loggedIn and (s:hasRole('sss') or s:hasRole('sssmgmnt'))}">
<redirect view-id="/secure/sss/home.xhtml"/>
</rule>
<rule if="#{identity.loggedIn}">
<redirect view-id="/secure/home.xhtml"/>
</rule>
</navigation>
next, you can restrict the pages, so only users with the right role can go there. In my pages.xml, I have the following lines:
<page view-id="/secure/upload.xhtml" login-required="true">
<restrict>#{s:hasRole('upload')}</restrict>
</page>

Resources