如何借助PrettyFaces将长Liferay URL映射到友好的URL?

时间:2012-11-27 10:40:27

标签: jsf liferay friendly-url prettyfaces

我想使用Liferay URL映射,但目前存在JSF 2和URL映射的错误,因此它不起作用(http://issues.liferay.com/browse/FACES-257)。所以我改用PrettyFaces。

我的问题是,你如何在PrettyFaces中映射像

这样的链接
localhost:8080/web/guest/wsw?p_auth=oPRD7ELs&p_p_id=KonakardPotrlets_WAR_KonakardPotrletsportlet&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_KonakardPotrlets_WAR_KonakardPotrletsportlet__facesViewIdRender=%2Fviews%2Fwizard.xhtml

这样的事情?

localhost:8080/web/guest/wsw/views/wizard/id=2

注意:我还需要生成一个新参数id,它在bean中设置。

1 个答案:

答案 0 :(得分:0)

FACES-257已在很久以前修复。您应该使用Liferay Friendly URLs

var cellWidthInLandscape: CGFloat = 0 { didSet { self.collectionView.reloadData() } } var lastIndex: Int = 0 override func viewDidLoad() { super.viewDidLoad() collectionView.dataSource = self collectionView.delegate = self NotificationCenter.default.addObserver(self, selector: #selector(rotated), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil) cellWidthInLandscape = UIScreen.main.bounds.size.width } deinit { NotificationCenter.default.removeObserver(self) } @objc func rotated() { // Setting new width on screen orientation change cellWidthInLandscape = UIScreen.main.bounds.size.width // Setting collectionView to previous indexpath collectionView.scrollToItem(at: IndexPath(item: lastIndex, section: 0), at: .right, animated: false) } override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { NotificationCenter.default.addObserver(self, selector: #selector(rotated), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil) } func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { // Getting last contentOffset to calculate last index of collectionViewCell lastIndex = Int(scrollView.contentOffset.x / collectionView.bounds.width) } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { // Setting new width of collectionView Cell return CGSize(width: cellWidthInLandscape, height: collectionView.bounds.size.height) } 下创建一个 friendly-url-routes.xml 文件:

src/main/resources/

您还需要将以下配置添加到 <?xml version="1.0"?> <!DOCTYPE routes PUBLIC "-//Liferay//DTD Friendly URL Routes 7.0.0//EN" "http://www.liferay.com/dtd/liferay-friendly-url-routes_7_0_0.dtd"> <routes> <route> <pattern>/views/{viewName}/id={my_id}</pattern> <generated-parameter name="_facesViewIdRender">/WEB-INF/views/{viewName}.xhtml</generated-parameter> <implicit-parameter name="p_p_lifecycle">0</implicit-parameter> <implicit-parameter name="p_p_mode">view</implicit-parameter> <implicit-parameter name="p_p_state">normal</implicit-parameter> </route> </routes> <portlet>部分:

liferay-portlet.xml

URL为:

<friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
<friendly-url-mapping>my-portlet</friendly-url-mapping>
<friendly-url-routes>friendly-url-routes.xml</friendly-url-routes>