【发布时间】:2017-08-13 17:03:27
【问题描述】:
我的 xhtml 中有以下代码:
<h:inputText binding="#{year}" />
<h:inputText binding="#{month}" />
<pretty:link value="Create" mappingId="pretty:addEntity">
<f:param name="year" value="#{year.value}" />
<f:param name="month" value="#{month.value}" />
Create Entity
</pretty:link>
我还得到了一个带有init 方法的bean,该方法用@URLAction(onPostback = false) 注释。
我想在这个方法中读取传递的参数。参数不在 JSF 的请求参数映射中,也不在查询字符串中(com.ocpsoft.pretty.PrettyContext.getCurrentInstance().getRequestQueryString())
如何将这些参数传递给 init 方法而不将它们绑定到支持 bean?
import com.ocpsoft.pretty.faces.annotation.URLAction;
import com.ocpsoft.pretty.faces.annotation.URLMapping;
import de.financeme.view.menu.NaviCase;
import javax.annotation.ManagedBean;
import javax.faces.bean.ViewScoped;
import lombok.Getter;
import lombok.Setter;
@ManagedBean
@ViewScoped
@URLMapping(id = "addEntity", pattern = "/entity/add", viewId = "/entity/add.xhtml")
public class Bean {
@Getter
@Setter
private String month;
@Getter
@Setter
private int year;
@URLAction(onPostback = false)
public void init() {
// month = null
// year = 0
}
}
即使将它们绑定到支持 bean。我没有调用任何提交函数。所以它们不会被存储到各自的字段中。
怎么了?我在这里错过了什么?
【问题讨论】:
-
请包含您的 bean 的代码和映射。
-
感谢您的提示!信息够了吗?
标签: jsf prettyfaces