-
1. Re: Help required in writing java code in seam framework
amitev Apr 15, 2010 2:57 PM (in response to vasukihn)Read Seam reference manual and Seam in Action.
As for the comobox i recommend you to fetch the values using @Factory and use the factory in the child selectItems of rich:combobox
-
2. Re: Help required in writing java code in seam framework
vasukihn Apr 23, 2010 9:08 AM (in response to vasukihn)Hi Adrian,
Can you give me an example java to explain the @Factory functionality?
-
3. Re: Help required in writing java code in seam framework
sappo Apr 23, 2010 11:31 AM (in response to vasukihn)Hi Vasuki,
check out the Seam reference manual:
http://docs.jboss.org/seam/2.2.1.CR1/reference/en-US/html_single/#d0e4355
For further reading I really recommand Seam in Action.
Kind regards,
Kevin -
4. Re: Help required in writing java code in seam framework
vasukihn Apr 27, 2010 9:38 AM (in response to vasukihn)Hi Kevin,
I have 2 entity files (Custom.java and CustomType.java). I want to have a list of CustomTypename(property of CustomType.java)as drop down in CustomEdit.xhtml file.
I have added CustomType class instance in Custom.java file and also setter and getter method for the instnace.
Later what i have to do? Just explain what functions to be written in which files?Thanks
Vasuki -
5. Re: Help required in writing java code in seam framework
sappo Apr 27, 2010 11:39 AM (in response to vasukihn)Hi Vasuki,
seam has build in support for converting entities. The only thing you've to do is add the s:convertEntity tag to your drop-down component.
<h:selectManyListbox value="#{yourBean.customTypeList}"> <s:selectItems var="c" value="#{yourBean.selectedType}" label="#{c.name}"/> <s:convertEntity/> </h:selectManyListbox>
//Kevin
-
6. Re: Help required in writing java code in seam framework
vasukihn Apr 27, 2010 1:04 PM (in response to vasukihn)Hi Kevin,
Please can you explain me in detail? I just have two entity files Custom.java and CustomType.java. I have added CustomType class instance in Custom.java and i have the getter and setter methods. Except this i have nothing else. What functions i have to write in each file? Once the functions are written what value should be passed to .xhtml file?
As i 'm new to this, please explain me in detail.
-
7. Re: Help required in writing java code in seam framework
sappo Apr 27, 2010 1:31 PM (in response to vasukihn)Hi Vasuki,
there is no need to change anything inside your entity classes. Just create an action class like the one below, to pass a list to your drop-down and obtain the selected value.
CustomTypeAction.java (you may want to change the scope):
@Name("customTypeAction") @Scope(ScopeType.SESSION) public class CustomTypeAction implements Serializable { @In EntityManager entitymanager; @Out List<CustomType> customTypeList; @In(required = false) CustomType selectedType; @Factory(value="customTypeList") public List<CustomType> initList() { return (ArrayList<CustomType>) entityManager.createQuery("select s from Schulform s").getResultList(); } }
*.xhtml
<h:selectManyListbox value="#{customTypeList}"> <s:selectItems var="c" value="#{selectedType}" label="#{c.name}"/> <s:convertEntity/> </h:selectManyListbox>
//Kevin
-
8. Re: Help required in writing java code in seam framework
vasukihn Apr 28, 2010 12:39 PM (in response to vasukihn)Hi Kevin,
As you said, I created CustomtypeAction.java file and wrote the code as you explained. I used my table name and fields in the query. Later added the belowcode to my CustomEdit.xhtml
<h:selectManyListbox value="#{customTypeList}"> <s:selectItems var="c" value="#{selectedType}" label="#{c.name}"/> <s:convertEntity/> </h:selectManyListbox>
When i add the above code to my CustomEdit.xhtml file i get the following error:
I didn't understand about var and label attributes of<s:selectItems>
tag.
java.lang.IllegalArgumentException: Expected a child component type of UISelectItem/UISelectItems for component type javax.faces.SelectMany(j_id41). Found null.
Can you guide where i am going wrong?