Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem on saving inputText values

 
sudha perumal
Greenhorn
Posts: 9
Eclipse IDE Java Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In selectonemenu's onchange process,some inputText fields get the values. But I cant save..

When saving the details, We have to call getter, setter methods.. How can I specify?


this is my xhtml code...

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
template="layout/template.xhtml">


<ui:define name="body">

<h:form id="quotation" styleClass="edit">

<rich:panel>
<f:facet name="header">#{quotationHome.managed ? 'Edit' : 'Add'} Quotation</f:facet>


<s:decorate id="quotationIdField" template="layout/edit.xhtml">
<ui:define name="label">Quotation id</ui:define>
<h:inputText id="quotationId"
disabled="#{quotationHome.managed}"
required="true"
size="12"
maxlength="12"
value="#{quotationHome.instance.quotationId}">
<a:support event="onblur" reRender="quotationIdField" bypassUpdates="true" ajaxSingle="true"/>
</h:inputText>
</s:decorate>


<s:decorate id="quotationDateField" template="layout/edit.xhtml">
<ui:define name="label">Quotation date</ui:define>
<rich:calendar id="quotationDate"
value="#{quotationHome.instance.quotationDate}" datePattern="MM/dd/yyyy" />
</s:decorate>
<s:decorate id="supplierIdField" template="layout/edit.xhtml">
<ui:define name="label">Supplier Name</ui:define>
<h:selectOneMenu id="supplierId" value="#{quotationHome.instance.supplierId}">
<f:selectItems value="#{supplierDetailsList.suppliers}" noSelectionLabel="Please Select..."/>
</h:selectOneMenu>
</s:decorate>

<s:decorate id="grandTotalField" template="layout/edit.xhtml">
<ui:define name="label">Grand total</ui:define>
<h:inputText id="grandTotal"
value="#{quotationHome.instance.grandTotal}">
<a:support event="onblur" reRender="grandTotalField" bypassUpdates="true" ajaxSingle="true"/>
</h:inputText>
</s:decorate>


<s:decorate id="descriptionField" template="layout/edit.xhtml">
<ui:define name="label">Description</ui:define>
<h:inputText id="description"
size="25"
maxlength="25"
value="#{quotationHome.instance.description}">
<a:support event="onblur" reRender="descriptionField" bypassUpdates="true" ajaxSingle="true"/>
</h:inputText>
</s:decorate>

<div style="clear:both">
<span class="required">*</span>
required fields
</div>
<rich:dataTable value="#{quotationHome.params}"
var="_p"
rowClasses="MasterListRow-0,MasterListRow-1"
styleClass="ListRowFont"
id="productdetailsesTable" rowKeyVar="i" >
<rich:column>
<f:facet name="header"><hutputText value="S.No." /></f:facet>
<hutputText value="#{i+1}" />
</rich:column>
<rich:column>
<f:facet name="header"><hutputText value="Item Name" /></f:facet>
<h:selectOneMenu id="itemName" value="#{_p.itemName}">
<a:support event="onchange" reRender="itemcode,pricevalue" ajaxSingle="true" actionListener="#{itemDetailsList.itemSearch(_p.itemName)}"/>

<f:selectItems value="#{itemDetailsList.items}" noSelectionLabel="Please Select..."/>

</h:selectOneMenu>
</rich:column>
<rich:column>
<f:facet name="header"><hutputText value="Item Code" /></f:facet>

<h:inputText id="itemcode" value="#{itemDetailsList.getItemprice(_p.itemCode,1)}" style=" width : 120px;"/>
</rich:column>
<rich:column>
<f:facet name="header"><hutputText value="Price" /></f:facet>

<h:inputText id="pricevalue" value="#{itemDetailsList.getItemprice(_p.itemName,2)}" style=" width : 120px;"/>

</rich:column>

<rich:column>
<f:facet name="header">
<hutputText value="Quantity" />
</f:facet>
<h:inputText value="#{_p.quantity}" style=" width : 100px;">
<a:support event="onkeyup" reRender="itemamount" ajaxSingle="true" actionListener="#{itemDetailsList.getAmountValue(_p.price,_p.quantity)}" />
</h:inputText>
</rich:column>
<rich:column>
<f:facet name="header"><hutputText value="Amount" /></f:facet>
<h:inputText id="itemamount" value="#{itemDetailsList.getAmountValue(itemDetailsList.getItemprice(_p.itemName,2),_p.quantity)}" style=" width : 100px;"/>
</rich:column>
<rich:column>
<f:facet name="header"><hutputText value="Action" /></f:facet>

<a:commandLink ajaxSingle="true" action="#{quotationHome.deleteRow(i)}" value="Delete" reRender="productdetailsesTable" bypassUpdates="true"/>

</rich:column>

</rich:dataTable>

<a:commandButton ajaxSingle="true" action="#{quotationHome.addNewRow}" value="Add" reRender="productdetailsesTable" />

</rich:panel>

<div class="actionButtons">

<h:commandButton id="save"
value="Save"
action="#{quotationHome.persist}"
disabled="#{!quotationHome.wired}"
rendered="#{!quotationHome.managed}"/>

<h:commandButton id="update"
value="Save"
action="#{quotationHome.update}"
rendered="#{quotationHome.managed}"/>

<h:commandButton id="delete"
value="Delete"
action="#{quotationHome.remove}"
immediate="true"
rendered="#{quotationHome.managed}"/>

<s:button id="cancelEdit"
value="Cancel"
propagation="end"
view="/Quotation.xhtml"
rendered="#{quotationHome.managed}"/>

<s:button id="cancelAdd"
value="Cancel"
propagation="end"
view="/#{empty quotationFrom ? 'QuotationList' : quotationFrom}.xhtml"
rendered="#{!quotationHome.managed}"/>

</div>
</h:form>

</ui:define>

</ui:composition>
 
Matt Kohanek
Village Idiot
Ranch Hand
Posts: 484
Java jQuery Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand you sorrectly, this is done in your faces-config.xml file.

You would define a managed bean that would be linked to your class that containes the setters and getters.



ANd just substitue in whatever name you want to name it for BeanName and substitue your package and class that has your setters and getters where I put package.class. Then on your xml page, when you want to save something, you would just do soething like this (using example from your code):



and just substitute attribute with whatever attribute your wnating to save the value to.

I think this is what your asking, if not my apologies
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic