playgrnd
@ 35
playgrnd / jsf-sample / src / main / java / com / uralian / sample / BidBean.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
/* * BidBean.java Jan 23, 2012 * * Copyright 2012 Uralian, LLC. All rights reserved. */ package com.uralian.sample; import javax.faces.application.FacesMessage; import javax.faces.bean.ManagedBean; import javax.faces.context.FacesContext; /** * @author Vlad Orzhekhovskiy */ @ManagedBean public class BidBean { private String userId; private double bidAmount; private Integer bidDuration; public String getUserId() { return userId; } public void setUserId(String userId) { this.userId = userId; } public String getBidAmount() { return Double.toString(bidAmount); } public void setBidAmount(String bidAmountStr) { try { this.bidAmount = Double.parseDouble(bidAmountStr); } catch (NumberFormatException e) { // nothing yet } } public Integer getBidDuration() { return bidDuration; } public void setBidDuration(Integer bidDuration) { this.bidDuration = bidDuration; } public String doBid() { FacesContext context = FacesContext.getCurrentInstance(); // if ("".equals(userId)) // context.addMessage(null, new FacesMessage("No user id", // "User id is required to place a bid")); if (bidAmount < 0.1) context .addMessage( null, new FacesMessage("Invalid bit amount", "Bid amount should be a valid number greater than or equal to $0.10")); // if (bidDuration < 15) // context // .addMessage( // null, // new FacesMessage("Invalid bit duration", // "Bid amount should be a valid number greater than or equal to 15 days")); if (context.getMessageList().size() > 0) return null; else return "show_bid"; } } |
Commits for playgrnd/jsf-sample/src/main/java/com/uralian/sample/BidBean.java
Revision | Author | Commited | Message |
---|---|---|---|
35 | snark | Thu 17 Aug, 2017 23:28:40 +0000 | add jsf-sample project |