Maximo List Archive

This is an archive of the Maximo Yahoo Community. The content of this pages may be a sometimes obsolete so please check post dates.
Thanks to the community owner Christopher Wanko for providing the content.



Re: [MAXIMO List] Refreshing record screen on update of child records

From: mattmaxdef (2013-01-31 03:11)

Hi Sean, thanks for that, it is much appreciated.
The code I'm basically using is below. Note I had to change a few things
for brevity, some of this is really broken up into other methods, but
the gist of it is here:
public int associateAssets() throws MXException, RemoteException
{
// Get the ID of X
MboRemote xMbo = this.app.getAppBean().getMbo();
int xId = xMbo.getInt("XID"); // Get the selected rows of the table
control
ControlInstance tabCtrl =
this.clientSession.findControl("table_of_assets");
DataBean tabDataBean = tabCtrl.getDataBean();
// Get the selected rows
Vector selTabRows = tabDataBean.getSelection();
Iterator tabRowIter = selTabRows.iterator();
// Build a where statement to fetch the ASSET MBOs into a MBOSet
String where = "";
while (tabRowIter.hasNext())
{
MboRemote assetItem = (MboRemote) tabRowIter.next();
where += "'" + assetItem.getInt("ASSETNUM") + "', ";
}
if (where.length() >= 0)
{
// Remove trailing comma and space from where statement
where = where.substring(0, where.length() - 2);
where = "ASSETNUM IN (" + where + ")"; // Build MBOSet from where
selection
MXServer mxSvr = MXServer.getMXServer();
UserInfo mxAdm = mxSvr.getUserInfo("MAXIMO-ADMIN-USERNAME");
MboSetRemote assetSet = mxSvr.getMboSet("ASSET", mxAdm);
assetSet.setUserWhere(where);
if ((assetSet != null)&&(!assetSet.isEmpty()))
{
MboRemote assetMBO = null;
int i = 0;
String assetNum; // Cycle through each MBO in the set and set the
XID field
while ((assetItem = assetSet.getMbo(i)) != null)
{
assetNum = assetItem.getString("ASSETNUM");
assetMBO.setValue("XID", xId);
i++;
}
// Save the set
assetSet.save();
assetSet.close();
////////////////////////////
// DO THE REFRESH HERE
////////////////////////////
}
}
// Close the dialog
WebClientEvent newEvent = new WebClientEvent("dialogclose",
this.app.getCurrentPageId(), null, this.clientSession);
this.clientSession.queueEvent(newEvent);
return EVENT_HANDLED;
}
So I tried adding as you suggested:
DataBean applicationBean = app.getAppBean();
MboSetRemote v_set = applicationBean.getMboSet();v_set.reset();
To where the //DO THE REFRESH HERE, it doesn't seem to do the trick...
--- In MAXIMO@yahoogroups.com, Sean Clark-McCarthy wrote:
>
> Try just calling the reset() method on the application's set.
>
> DataBean applicationBean = app.getAppBean();
> MboSetRemote v_set = applicationBean.getMboSet();
> v_set.reset();
>
> p.s. been awhile since I've done beans. Would probably help too if we
had the code snippet you're working with at least in pseudo form.
>
> --- Sean Clark-McCarthy
>
> From: MAXIMO@yahoogroups.com [mailto:MAXIMO@yahoogroups.com] On Behalf
Of mattmaxdef
> Sent: Wednesday, January 30, 2013 6:15 PM
> To: MAXIMO@yahoogroups.com
> Subject: Re: [MAXIMO List] Refreshing record screen on update of child
records
>
>
>
> Hi Chris,
>
> I'm sorry if I'm not explaining it very well!
>
> > Are you displaying the related assets in application X in a table?
>
> Yes, the X application shows the related assets. OK, so let's imagine
X table has the attributes:
>
> XID - Unique identifier
> NAME
> DESCRIPTION
> (Other attributes)
>
> ASSET Table has been modified by adding a new attribute 'XID'.
>
> On 'X' table a new relationship is added:
>
> Relationship: XASSETS
> Child Table: ASSET
> Where: XID = :XID and SITEID = :SITEID
>
> On the application for X, a table control is added:
>
> Label: Related Assets
> Relationship: XASSETS
>
> So now the X application shows all the related assets to a record of
X. That is, where the ID of X (XID) equals the XID column in the ASSET
table.
>
> > Do you modify the asset in the Assets module or are you looking to
do the modification from within application X?
>
> I'm looking to the modification from within the application X. This is
now being done through a Java bean.
>
> > Can you describe what you have in application X in regard to the
assets and how you are wanting the UI to work?
>
> -- The following is what is working now --
>
> There is a button below the table control I created in the X
application called 'associate assets'. It fires an event that launches a
custom dialog. This dialog shows a table of assets (MBO=ASSET). This
table has checkboxes for each row so the user can select one or more
asset. The dialog has a button called 'OK'.
>
> The OK button runs a method in the custom java bean called
'associateAssets'. This method scans through that table, picks out the
rows that are checked, and builds an MboSet of all the assets selected
by the user. The java code then cycles through those ASSET MBOs and
modifies the 'XID' field, setting it to the ID of the current X record
being displayed in the X application.
>
> These assets are now 'associated' with that X record. And if I exit
the application and go back to the record, the table I created in the X
application will show the appropriate assets related.
>
> -- What I can't get working --
>
> When the user presses OK and the java bean updates the asset records,
the dialog then closes. However the table control in the application
does not refresh to show the updates the bean has made to the ASSET
records. So the assets that the user has selected in the dialog do not
show up in this table.
>
> It is important to note: The database HAS changed, the assets have
been modified in the the database at this point. If I exit from this
application, go back into the application and select the same record,
the table looks as it should (i.e. those asset records user has selected
now appear in that table control).
>
> I need a way to 'reload' this table control in the java bean once it
has made the changes to the asset table. I need to tell it 'go and
re-execute that relationship'. That is, clear the table, find all assets
where XID = :XID as through the XASSETS relationship.
>
> This will (in my totally uninformed opinion) probably be a call to a
method in the java bean, right before or after the dialog closes.
Something like:
>
> refreshTable();
>
> This is a method available, but it doesn't do anything.
>
> > If the expectation is that while one user is viewing a record in
application X another user relates an asset to that record then the
first user's session will have no awareness of this without a user
initiated refresh.
>
> No, we I'm only talking about one user here. Once he/she launches the
dialog, associates the assets, the table needs to refresh in the X
application to reflect the changes the java bean has performed.
>
> I hope that explains it better!
>
> --- In MAXIMO@yahoogroups.com , Chris Lawless wrote:
> >
> > I don't know if others are clear but I'm not sure I fully understand
what
> > you are expecting to see refresh and when. As I interpret this you
have a
> > reference on ASSET that indicates that it is linked to a record in
> > application X - lets say LOCATIONS for sake of argument. Are you
displaying
> > the related assets in application X in a table? If so how is the
> > relationship created, do you modify the asset in the Assets module
or are
> > you looking to do the modification from within application X?
> >
> > If you are doing it in application X then how...? Without an
intermediate
> > relationship you cannot create a link without modifying an asset
from
> > within X which would be complicated unless you are using an action
or
> > similar. Can you describe what you have in application X in regard
to the
> > assets and how you are wanting the UI to work?
> >
> > If the expectation is that while one user is viewing a record in
> > application X another user relates an asset to that record then the
first
> > user's session will have no awareness of this without a user
initiated
> > refresh.
> >
> > Chris.
> >
> > On Tue, Jan 29, 2013 at 6:17 PM, mattmaxdef wrote:
> >
> > > **
> > >
> > >
> > > Hi Chris,
> > >
> > > Thanks for your reply.
> > >
> > > Yeah it is a one-to-many cardinality, so many assets to one 'X'
object.
> > > This means I shouldn't need a mapping table - I just created a
field in the
> > > ASSET table that that is a foreign key to the primary key of the
'X'
> > > object. This all works fine through the application. There is no
deleting
> > > or adding of ASSETS in the process, all it is doing is setting
this ID
> > > field in the ASSET table to relate the asset to the 'X' object. So
the
> > > application either sets it to the ID of X to relate it, or sets it
to NULL
> > > to un-relate it.
> > >
> > > The actual modification of the database data works all fine. The
only
> > > thing I can't do is get the application to refresh after I've made
the
> > > database changes. When I'm talking about 'refreshing a table' in
this case
> > > I mean an application control - not a database table. The
application
> > > control needs to refresh to reflect the changes the application
has made to
> > > the database - i.e. unrelating or relating assets to the X object.
> > >
> > > Cheers!
> > >
> > > --- In MAXIMO@yahoogroups.com , "Hanna, Christopher CTR" wrote:
> > > >
> > > > Depending on the cardinality between the two objects, you may
need a
> > > breakout table to make this work. I did something very similar
with a clone
> > > of lease contracts for locations instead of assets. The breakout
table
> > > simply contains the keys of the two objects to be related
(absolutely
> > > necessary to implement a many to many relationship), so in the
application,
> > > you simply create or delete records in the breakout table. This
allows the
> > > application delete and create to work because you are
creating/deleting
> > > records in the breakout table as opposed to creating records in
the ASSET
> > > object, so it can simply be done through the app.
> > > >
> > > > -Chris H
> > > >
> > > > -----Original Message-----
> > > > From: MAXIMO@yahoogroups.com [mailto:MAXIMO@yahoogroups.com ] On
Behalf
> > > Of mattmaxdef
> > > > Sent: Monday, January 28, 2013 7:36 PM
> > > > To: MAXIMO@yahoogroups.com
> > > > Subject: Re: [MAXIMO List] Refreshing record screen on update of
child
> > > records
> > > >
> > > >
> > > >
> > > > Hi Shannon,
> > > >
> > > > Thanks for your reply, it is much appreciated.
> > > >
> > > > Yep, I've created a new table and the custom application bound
to that
> > > table. I've done it all through the database configurator module
and
> > > application designer.
> > > >
> > > > What I'm talking about here is showing a table in that
application which
> > > I've created, trying to show a list of related records to that new
custom
> > > table. In this case it's the ASSET table, since one or more assets
are
> > > related to a record in this custom table.
> > > >
> > > > So it's easy to show the records via a relationship I've set up
in the
> > > database configurator, but I want the user to be able to relate
more assets
> > > and remove the relationship.
> > > >
> > > > Sorry if I've misinterperated your reply.
> > > >
> > > > Cheers!
> > > >
> > > > --- In MAXIMO@yahoogroups.com , "Incomm Solutions Inc." wrote:
> > > > >
> > > > > You actually don't need to do this with Java . just go into
DBConfig
> > > > > and create a new table to hold the data you want, then go into
> > > > > Application Designer and create a new custom application
that's bound
> > > to the table.
> > > > > See the section on "Creating an Application" in the
Application
> > > > > Developer's Guide for more info.
> > > > >
> > > > >
> > > > >
> > > > > Note: it's definitely recommended that you do it using the
Maximo
> > > > > internal tools, since that makes it visible to the Maximo
upgrade
> > > > > tools and other functions in Maximo. Likewise I strongly
recommend
> > > > > against adding new tables and/or new indexes outside of the
Database
> > > > > Configuration application
> > > > > - it makes life difficult down the line, since Maximo is not
aware of
> > > > > the changes.
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Shannon Rotz
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > From: MAXIMO@yahoogroups.com
> > > > > [mailto:MAXIMO@yahoogroups.com ] On
> > > > > Behalf Of mattmaxdef
> > > > > Sent: January-27-13 10:33 PM
> > > > > To: MAXIMO@yahoogroups.com
> > > > > Subject: [MAXIMO List] Refreshing record screen on update of
child
> > > > > records
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > OK, I've only been working with MAXIMO for 2 weeks so you'll
have to
> > > > > bear with me if I'm using terms wrong etc. Sorry in advance.
> > > > >
> > > > > Customer wants a new MBO called X, where the ASSET table has a
child
> > > > > relationship to X by having the column XID. XID is the ID of
the X
> > > table.
> > > > >
> > > > > The desired outcome is very similar to a CONTRACT in MAXIMO
having
> > > > > associated assets.
> > > > >
> > > > > Everything is setup in a custom application where users can
modify X's
> > > > > fields etc. It has a table that shows all assets that are
related to
> > > > > the record through the relationship.
> > > > >
> > > > > I wanted the ability to associate or disassociate the assets
to X from
> > > > > this application. So I added a button that launches a dialog,
showing
> > > > > table of all the assets and they can check the desired assets
and the
> > > > > application java code will set XID on the selected asset
records to
> > > > > the ID of the X record.
> > > > >
> > > > > Similarly a button on the X application allows users to select
> > > > > associated assets from the table and the java code upon
pressing the
> > > 'disassociate'
> > > > > button will set XID on the selected assets to NULL.
> > > > >
> > > > > This all works fine, except for the life of me I cant get the
> > > > > application to refresh the table that shows the assets
associated to
> > > > > X. So even when a user associates or disassociates assets, the
table
> > > > > remains the same. However if you exit from that record and go
back
> > > into it, you can see the changes made.
> > > > >
> > > > > I've tried calling the following methods at the end of each
function:
> > > > >
> > > > > fireDataChangeEvent();
> > > > > fireChildChangedEvent();
> > > > > fireStructureChangedEvent();
> > > > > refreshTable();
> > > > >
> > > > > None of them seem to do what is desired.
> > > > >
> > > > > Has anyone got any ideas? Thanks in advance!
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > >
> > >
> > >
> >
> >
> >
> >
>
>
>
>
>