Tag: 导航

保留JSF表单提交的GET请求查询字符串参数

我有3页: main.xhtml agreement.xhtml generated.xhtml agreement.xhtml需要两个参数来正确加载: serviceId和site 。 所以,一个普通的url看起来像这样: /app/agreement.xhtml?site=US&serviceId=AABBCC 。 我在agreement.xhtml上有这个按钮 <h:form> <h:commandButton value="Generate License File" action="#{agreement.generateMethod}" /> </h:form> @RequestScoped bean #{agreement}有这个方法: public String generateMethod(){ ……. return "generated"; } 我需要的是,单击时,执行generateMethod()方法,完成后,用户被重定向到generated.xhtml页面。 发生的事情是,单击页面浏览器将用户发送到/app/agreement.xhtml ,因为它不发送参数site和serviceId ,它崩溃。 我试着让generateMethod()返回一个"generated?faces-redirect=true" ,但还是什么都没有。 有任何想法吗?

重定向和导航/转发和何时使用什么有什么区别?

JSF中的导航有什么区别? FacesContext context = FacesContext.getCurrentInstance(); context.getApplication().getNavigationHandler().handleNavigation(context, null, url); 和重定向 HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse(); response.sendRedirect(url); 以及如何决定何时使用什么? 导航问题是,除非将faces-redirect=true添加到导航URL的查询字符串,否则页面URL不会更改。 但是,在我的情况下,如果我想重定向到一个非JSF页面,如普通的HTML页面,appending faces-redirect=true会抛出错误。 另一个选项是BalusC在JSF 2.0重定向错误时提示的

相同的导航抽屉在不同的活动

我制作了一个工作的抽屉,就像在developer.android.com网站的教程中显示的那样。 但现在,我想使用一个导航抽屉,我在NavigationDrawer.class中为我的应用程序中的多个活动创建。 我的问题是,如果任何人在这里可以做一个小教程,这解释了如何使用一个导航抽屉多个活动。 我首先阅读它在这个Android的导航抽屉在多个活动 但是它在我的项目上不起​​作用 public class NavigationDrawer extends Activity { public DrawerLayout drawerLayout; public ListView drawerList; private ActionBarDrawerToggle drawerToggle; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); drawerToggle = new ActionBarDrawerToggle((Activity) this, drawerLayout, R.drawable.ic_drawer, 0, 0) { public void onDrawerClosed(View view) { getActionBar().setTitle(R.string.app_name); } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(R.string.menu); } }; […]