【发布时间】:2009-11-10 03:01:52
【问题描述】:
我不知道这是否可能,但我想要类似的东西
<f:view>
<h:form>
<div>
<label for="accountId">Type your account id</label>
<input type="text" name="accountId"/>
</div>
<div>
<label for="amount">Type amount</label>
<input type="text" name="amount"/>
</div>
<div>
<!--NOTICE IT IS #{accountService.deposit} -->
<!--BUT I WANT TO USE #{accountService.deposit(accountId, amount)} -->
<h:commandButton action="#{accountService.deposit}" value="Deposit amount"/>
</div>
</h:form>
</f:view>
还有我的服务
@Stateless
@Name("accountService")
public class AccountServiceImpl implements AccountService {
@RequestParemeter
protected Integer accountId;
@RequestParemeter
protected double amount;
@PersistenceContext
private EntityManager manager;
public void deposit() {
Account account = manager.find(Account.class, accountId);
account.deposit(amount);
}
}
碰巧我想用这个而不是上面显示的
@Stateless
@Name("accountService")
public class AccountServiceImpl implements AccountService {
@PersistenceContext
private EntityManager manager;
public void deposit(Integer accountId, double amount) {
Account account = manager.find(Account.class, accountId);
account.deposit(amount);
}
}
有可能吗?如果是这样,我应该使用什么 - 事件或其他东西 - 来实现我的目标?
问候,
【问题讨论】:
-
嘿亚瑟,你为什么不把其他论坛的答案作为你自己问题的答案。