[JBoss Seam] - Re: Avoiding the DRY Principle with beans
by iradix
If you're concerned about typing, throw some generics in there.
public abstract class PersistentBean<T> implements Serializable, PersistentLocal {
|
| @PersistenceContext(unitName="hrsystem",
| type=PersistenceContextType.EXTENDED)
| private EntityManager entityManager;
|
| public abstract void setObject(T object);
|
| public abstract T getObject();
|
| public String update() {
| entityManager.merge(getObject());
| return "Success";
| }
|
| public String create() {
| entityManager.persist(getObject());
| return "Success";
| }
|
| public String delete() {
| entityManager.remove(getObject());
| return "Success";
| }
| }
@Stateful
| @Name(value="employeeBean")
| public class EmployeeBean extends PersistentBean<Employee> {
|
| public EmployeeBean() {
| }
|
| @In(create = true) @Out
| private Employee object;
|
| public void setObject(Employee object) {
| this.object = object;
| }
|
| public Employee getObject() {
| return object;
| }
|
| }
Should work. Pretty cool huh? Now not only will your outjected object work in your jsf pages, any other methods you add in your subclass will have the correct type to work with.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3957520#3957520
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3957520
19 years, 9 months
[JBoss Seam] - Re: Beginning conversations in @Factory methods
by gavin.king@jboss.com
"iradix" wrote : Ok Gavin, let me try to explain. I have a page that outputs a DataTable of objects. A user can click on an object's name to select it and bring up an update form or use a button below the list to bring up a form for new object creation. When either of these forms is successfully submitted, the user is returned to the page with the DataTable
|
| I want to set the conversation that the @DataModel is outjected into as long running so that when the postback occurs for a selection and my @DataModelSelection is injected it will be sure to come from the same @DataModel displayed to the user.
|
| When a new object is created, I want to end the conversation so that the @DataModel, which was retrieved using a now stale query and any state associated with it is dropped before the page with the DataTable is redisplayed.
|
| So therein lies my problem. If I begin the conversation from the page containing the DataTable and the conversation is ended by an action method that redisplays that page, the conversation will always be restarted, even after issuing a redirect.
|
| Make sense?
|
| I'm not married to doing things this way, but it's the best I've come up with, so if it can be done differently please point me in the right direction.
|
| -Dave
|
|
So you have
(1) A conversational search screen
I usually recommend that search screens be page scoped, session scoped, or even purely stateless.
http://blog.hibernate.org/cgi-bin/blosxom.cgi/2006/06/22#stages-of-adoption
(2) A conversation that edits the data and then returns to the search screen
Shouldn't it be a nested conversation then?
(3) the need to update the search screen when done editing the data
why not just use a Seam event that forces refresh of the list (just like the booking list in the booking demo)
Have I understood everything here?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3957519#3957519
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3957519
19 years, 9 months
[JBossWS] - Cannot find child element: int_1
by burakbayramli
I successfully compiled, deployed and tested a WebService using pure Java. However, I experience problems when I test the service through a VBS (VB script). The exception I get is; java.xml.rpc.JAXRPCException: Cannot find child element: int_1
| @WebService
| @SOAPBinding(style=Style.RPC)
| public interface Calculator extends Remote
| {
| @WebMethod int add(int x, int y);
|
| @WebMethod int subtract(int x, int y);
| }
| @Stateless
| @WebService(endpointInterface="org.bilgidata.kitapdemo.service.Calculator")
| public class CalculatorBean
| {
| public int add(int x, int y)
| {
| return x + y;
| }
|
| public int subtract(int x, int y)
| {
| return x - y;
| }
| }
The calling VBS script is
| set soapclient = CreateObject("MSSOAP.SoapClient30")
|
| On Error Resume Next
| url = "http://localhost:8080/kitapdemo/CalculatorBean?wsdl"
| Call soapclient.mssoapinit(url, "", "")
|
| if err <> 0 then
| Wscript.echo "initialization failed" + err.description
| end if
|
| wscript.echo soapclient.add(1,2)
|
| if err <> 0 then
| wscript.echo err.description
| end if
|
Any help would be appreciated.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3957518#3957518
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3957518
19 years, 9 months
[JBoss Seam] - Re: Beginning conversations in @Factory methods
by iradix
anonymous wrote : You could reload the object when the conversation starts?
I'm not sure I follow.
anonymous wrote : If this ID is being added as a request param please make sure that it's a non-important ID (ie, not a DB key). If it is, you run the risk of a malicious user accessing or possibly updating data they shouldn't via manipulation of this request param.
I've got to agree with the captain on this one :) Passing an id is the way I've always done this in the past, but the security concerns/workarounds are a good reason for the JSF DataModel usage in the first place. In order for the DataModel to work however, it needs to stay consistent between the rendered response and the postback. I can't serialize it, so it seems to make sense that I would store it in the conversation, which means starting the conversation from the page that requests the @DataModel.
CptnKirk, do you have a different method for handling this?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3957517#3957517
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3957517
19 years, 9 months