Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

A question regarding ICEFACES

  Asked By: Ayden    Date: Sep 19    Category: Java    Views: 1918
  

In one of my webapplication i'm using icefaces + seam. i've a web page which enable the user to fill a form. User can choose a category by using a selectOneMenu and the selection of category will be send to the server and will be shown to the user. I'm using following to show the web page with the form fields:


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

<!-- content -->
<ui:define name="content">
<f:loadBundle basename="localization.application" var="bundle" />
<ice:panelGroup id="contentAddAdvertismentPage">
<div class="section">
<ice:form>
<ice:panelTabSet stylclass="panelTabSet" tabPlacement="top" id="panelTabSetIDAddAdvertismentPage">
<ice:panelTab id="panelTabIDAddAdvertismentPage2" label="New Advertisement" rendered="true">

<ice:panelGrid columns="2" rendered="true">
<ice:inputText id="advTitleINP" value="#{selectedAdvertisement.title}"/>
<ice:outputText id="advTitleOUP" value="title" styleClass="valueHeader"/>
</ice:panelGrid>

<ice:selectOneMenu value="#{selectedAdvertisement.title}"
partialSubmit="true" immediate="true" >
<f:selectItems value="#{advertisementCategoryDataAction.componentList}" />
</ice:selectOneMenu>

<div id="EditChooseBox" class="buttonBox">
<ice:commandButton id="Saveadvertisementbutton" value="Save" action="#{advertisementHandle.saveAdvertisement}"/>
 
<s:button id="cancelEditViewing" value="Cancel" view="/userpage.xhtml"/>
</div>
</ice:panelTab>
</ice:panelTabSet>
</ice:form>
</div>
</ice:panelGroup>
</ui:define>
</ui:composition>

If the user do not choose any category, it get a defalut category otherwise he will see the category in another fields. The problem is that after user action, the selectOneMenu jump to its default category(first category in the list). Probably "ice:selectOneMenu" element will also be refreshed. How can i solve this problem?

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Jamie Williams     Answered On: Sep 19

I'm not sure whether "advertisementCategoryDataAction.componentList"
is a collection of string or not. but I guess
selectedAdvertisement.title is a String.
Probably you've bound the selectItems tag lib to a collection of
object and the selectOneMenu to a String. So there is an
incompatibility in types.

I suppose that advertisementCategoryDataAction.componentList is a
collection of YourComponent class which has a member called title. You
must override the equals method and compare the input argument with
this.title. Something like this


public class YourCompoenent {

public String getTitle() {...}
public void setTitle(String title) {...}

@Override
public boolean equals(Object object) {

if(object instanceof String)
return this.getTitle().equals(object);
}
return super.equals(object);
}

}

 
Answer #2    Answered By: Darrell Harvey     Answered On: Sep 19

You have list  of selectItem that you refer them as
{adevertisementCategoryDataAction.componentList}
that each of that (SelectItem Object), have lable (as String) and
value (as Object),
that this list bind to your component and on other hand you have one
property (selectedAdvertisement.title) for selected index.

i think the problem  here is your {selectedAdvertisement.title}
property type, is not equivalent to SelectItem value property type, so
can not bind properly and always select the first item of SelectItems.

i mean if your value property type in your selectItem (componentList)
is Long
the title property on selectedAdvertisement must be Long.

 
Didn't find what you were looking for? Find more on A question regarding ICEFACES Or get search suggestion and latest updates.




Tagged: