Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem in sending variable to backing bean

843844Mar 31 2008 — edited Apr 1 2008
I want to send the data selected by the user that retrieved from the database to the backing bean. I have two questions. First, I don't know why the variable irl, irw, ird cannot display in the inputbox. Second, when the user click the commandbutton, it will throw NullPointerException. Please help. Thanks.

Code of the JSF
  			<sql:query sql = "SELECT PLI_ITEM_NO,PLI_RD_CODE,PLI_TRNH_LEN,PLI_TRNH_WID,PLI_TRNH_DEP FROM PLI_PLAN_ITEM WHERE PLI_PLAN_ID = ${pid} AND PLI_ITEM_NO = ${iid}" var = "itemresult" dataSource="${db}">
  			</sql:query>

  			<table id="ro-item" cellspacing="0" cellpadding="3" border="0">
  				<c:forEach var="itemrow" items="${itemresult.rows}">
  					<c:set var="irl" value="${itemrow.PLI_TRNH_LEN}"/>
  					<c:set var="irw" value="${itemrow.PLI_TRNH_WID}"/>
  					<c:set var="ird" value="${itemrow.PLI_TRNH_DEP}"/>
  					<tr>
  						<td>Road Category:</td>
  						<td></td>
  					</tr>
  					<tr>
  						<td>Length:</td>
  						<td>
  							<h:inputText id="itemlength" value="#{irl}" size="6"></h:inputText>m
  						</td>
  					</tr>
  					<tr>
  						<td>Width:</td>
  						<td>
  							<h:inputText id="itemwidth" value="#{irw}" size="6"></h:inputText>m
  						</td>
  					</tr>
  					<tr>
  						<td>Depth:</td>
  						<td>
	  						<h:inputText id="itemdepth" value="#{ird}" size="6"></h:inputText>m
  						</td>
  					</tr>
  				</c:forEach>	
  			</table>

			<c:if test="${irl==null}"><c:set var="irl" value=""/></c:if>
  			<c:out value="${irl}"/>
  						
		    <h:commandButton id="submit" value="Submit" actionListener="#{planBean.action}">
		        <f:attribute name="attributeName1" value="#{irl}" />
    		</h:commandButton>
Code of the backing bean
public class PlanBean {
    
    public void action(ActionEvent event) {
        String attributeName1 = FacesUtil.getActionAttribute(event, "attributeName1");
        System.out.println("attributeName1: " + attributeName1);
    }

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 29 2008
Added on Mar 31 2008
3 comments
102 views