Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在游戏中管理页面流!框架标签_Java_Playframework_Page Flow - Fatal编程技术网

Java 在游戏中管理页面流!框架标签

Java 在游戏中管理页面流!框架标签,java,playframework,page-flow,Java,Playframework,Page Flow,在一个使用Play框架构建的web应用程序中,我有一个签出页面,其中列出了用户的购物车以及地址表。我将地址表单创建为标记(addressform.html),以便可以重用 checkout.html: #{if shopcart.cartItems} #{shopcartview customer:customer,shopcart:shopcart/} #{addressform customer:customer /} #{/if} 地址表单有一个表单元素{form@set

在一个使用Play框架构建的web应用程序中,我有一个签出页面,其中列出了用户的购物车以及地址表。我将地址表单创建为标记(addressform.html),以便可以重用

checkout.html:

#{if shopcart.cartItems}
    #{shopcartview customer:customer,shopcart:shopcart/}
    #{addressform customer:customer /}
#{/if}
地址表单有一个表单元素
{form@setAddressInfo()}

它调用一个控制器方法,如下所示

public static void setAddressInfo(Long customerId,...) {
   ...
   showPaymentPage();
}
如果一切顺利,就会转到付款页面

当我想重用我的
确认人
页面上的
地址表单
时,就会出现问题

confirmOrder.html:

#{if shopcart.cartItems}
        #{shopcartview customer:customer,shopcart:shopcart/}
        #{addressform customer:customer /}
#{/if}

<a href="link_to_payment_page">editPaymentInfo</a>
#{if shopcart.cartItems}
#{shopcartview客户:客户,shopcart:shopcart/}
#{addressform customer:customer/}
#{/if}
在这里,如果用户更改地址并提交表单,成功完成后,
setAddressInfo()
方法将打开付款页面。这并不好——用户可能根本不想更改付款信息。此外,我还为那些想要更改付款信息的用户提供了一个到付款页面的链接。我希望显示相同的订单确认页面,以便用户可以单击
提交订单
按钮


那我该怎么做呢?在这种情况下,我当然可以重复使用地址表,对吗?在这种情况下,您能帮我找出如何管理页面流吗?

您可以提供一个参数,指示将用户重定向到何处,通过隐藏输入或类似java参数的方式重定向到setAddressInfo()。两种选择:

<input type="hidden" name="urlToRedirectUserTo" value="urlToRedirecTo(maybe using @{}..)"/>
在行动中,你会:

public static void setAddressInfo(String urlToRedirectUserTo) { 
   ...
   ...
   ...
   redirect(urlToRedirectUserTo);
}

有更好的选项可以使它更类型化、更不容易出错,但这一个可能已经足够好了。

您可以提供一个参数,指示将用户重定向到何处,通过隐藏输入或类似java参数的方式重定向到setAddressInfo()。两种选择:

<input type="hidden" name="urlToRedirectUserTo" value="urlToRedirecTo(maybe using @{}..)"/>
在行动中,你会:

public static void setAddressInfo(String urlToRedirectUserTo) { 
   ...
   ...
   ...
   redirect(urlToRedirectUserTo);
}

有更好的选项可以使其更易于键入和更少出错,但这一个可能已经足够好了。

简单地说,您可以在addressform标签上添加一个标志,上面写着“是否在末尾重定向到付款”…将来请在
之后使用空格(在句子末尾),并在逗号之后使用空格,不在前面。简单地说,您可以在addressform标签上添加一个标志,上面写着“是否在末尾重定向到付款”……以后请在
(句子末尾)之后使用空格,并在逗号之后使用空格,而不是在前面。