Custom Button Rendering/Disabling with Velocity Templates [SOLVED]

I have a custom button in my application that I only want to show up on specific pages and I can't seem to figure out a EL expression that will let me disable or not render the button on the following criteria,
- The velocity template will be installed on tableForm configured groups.
- I only want the button to be activated/visable when in the 'Details' view for a specific row
- When the group has insertions permitted.
I have tried to steal some code from the *.vm files for other buttons and items used by JHeadstart, but none of the expressions seem to be solving my problem. I have always found the Data Binding through EL Expressions with the ADF very confusing to work with so any guidance would be greatly appreciated. (Is there a way to 'debug' EL expressions to see the actual data that is available to me at any given time?)
Thanks.
Message was edited by:
M.Ruston
Message was edited by:
M.Ruston

My Case is :
The code of my button in Custom Template :
<af:commandButton text="Zone Charge Group Details"
rendered="true" disabled="false" immediate="true" >
<f:actionListener type="oracle.jheadstart.controller.jsf.listener.DoRollbackActionListener"/>
<af:resetActionListener/>
</af:commandButton>
my Custom Template is running successfully and button appear in runtime
But I want re-write this code so that this button is binded with a method in Managed Bean
Scenario is :
when click the button in a page, it calls a method in that Bean and pass a parameter to it.
And the ouptut of this method is displayed in another page.
There is no Error message....
Please, If you don't understand anything, Ask me .
My Question is :
How to bind Button to a Method in a custom Template?
Please,Reply me ASAP.
Thank you very much.
Rabab Youssef,
J2EE Developer

Similar Messages

  • Rendering error with wrong template path

    Hi there,
    I got a processing exception during a "Render" operation. I think the problem is shown in the following log entries on the server with Adobe Document Services installed (ADS). The application is running on another system (AS1):
    com.adobe.ads.remote.EJB_PDFAgent: Embedding of file/stream: DatasheetView_InteractiveForm.xdp using ID: template0 Failed:
    Unable to create a FileDataBuffer for: E:\usr\sap\AS1\J00\j2ee\cluster\apps\company.de\sheetwd\servlet_jsp\webdynpro\resources\company.de\sheetwd\root\WEB-INF\webdynpro\Components\de.company.sheet.wd.datasheet.Datasheet\DatasheetView_InteractiveForm.xdp
    ... Continuing with Embedding files ...
    The path "E:\usr\sap\AS1\J00..." does not exists on the Server with Adobe document services installed. Its SID is "ADS".
    Caused by: com.adobe.ProcessingException: File not found: E:\usr\sap\AS1\J00\j2ee\cluster\apps\company.de\sheetwd\servlet_jsp\webdynpro\resources\company.de\sheetwd\root\WEB-INF\webdynpro\Components\de.company.sheet.wd.datasheet.Datasheet\DatasheetView_InteractiveForm.xdp
    at com.adobe.ads.operation.Render.execute(Unknown Source)
    at com.adobe.ads.operation.ADSOperation.doWork(Unknown Source)
    ... 85 more
    Caused by: com.adobe.ProcessingException: File not found: E:\usr\sap\AS1\J00\j2ee\cluster\apps\company.de\sheetwd\servlet_jsp\webdynpro\resources\company.de\sheetwd\root\WEB-INF\webdynpro\Components\de.company.sheet.wd.datasheet.Datasheet\DatasheetView_InteractiveForm.xdp
    at com.adobe.ads.data.FileURLData.getInputStream(Unknown Source)
    at com.adobe.ads.data.URLData.getByteArray(Unknown Source)
    at com.adobe.ads.data.TemplateCacheInfo.<init>(Unknown Source)
    at com.adobe.ads.data.TemplateCacheInfo.getInstance(Unknown Source)
    at com.adobe.ads.operation.support.Template.setCacheInfo(Unknown Source)
    at com.adobe.ads.operation.support.Template.initialize(Unknown Source)
    at com.adobe.ads.operation.Render.initializeTemplates(Unknown Source)
    at com.adobe.ads.operation.Render.initializeSources(Unknown Source)
    at com.adobe.ads.operation.Render.initialize(Unknown Source)
    ... 87 more
    Caused by: java.io.FileNotFoundException: E:\usr\sap\AS1\J00\j2ee\cluster\apps\company.de\sheetwd\servlet_jsp\webdynpro\resources\company.de\sheetwd\root\WEB-INF\webdynpro\Components\de.company.sheet.wd.datasheet.Datasheet\DatasheetView_InteractiveForm.xdp (The system cannot find the path specified)
    at java.io.FileInputStream.open(Native Method)
    Any ideas
    Thanks ahead

    Hello,
    I think at the moment you are passing the xdp template source as url using the WDURLGenerator.
    Instead you should send it as a stream using the appropriate pdfdocument api like this:
    String templateUrl = null;
    ByteArrayOutputStream templateStream = null;
    templateUrl = WDURLGenerator.getPublicResourcePath(otherPart, "My_InteractiveForm.xdp");
    InputStream template = new FileInputStream(templateUrl);
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
                  int nRead;
                  byte[] data = new byte[16384]; 
                  while ((nRead = template.read(data, 0, data.length)) != -1) {
                            buffer.write(data, 0, nRead);
                  buffer.flush(); 
                  templateStream = buffer;
    IWDPDFDocumentHandler pdfDocumentHandler = WDPDFDocumentFactory.getDocumentHandler();
    IWDPDFDocumentCreationContext pdfDocumentCreationContext = pdfDocumentHandler.getDocumentCreationContext();
    pdfDocumentCreationContext.setTemplate(templateStream);
    Hope this helps...
    Regards, Bernd

  • Using a Velocity Template in Java User Exit Custom Handler

    I would have thought it would be possible to use a Velocity template in combination with a custom handler in a Java user exit, but I can't seem to figure out how  to do it, and I'm not finding an example of doing this anywhere in the GoldenGate docs.
    For example, I can create a Velocity template and use it to output transactions in the desired format to a file by using a propeties file that looks something like this:
    gg.handlerlist=myhandler
    gg.handler.myhandler.mode=tx
    gg.handler.myhandler.format=./dirprm/my_template.vm
    gg.handler.myhandler.type=file
    gg.handler.myhandler.file=my_output.txt
    What I'm hoping to do is to have a custom handler, and some how  be able to get to the Velocity formatted transaction data in the "transactionCommit(DsEvent, DsTransaction)" method of my custom extension of AbstractHandler by having a properties file that looks like this (same as the above, except for the type, and no file property ... eg:
    gg.handlerlist=myhandler
    gg.handler.myhandler.mode=tx
    gg.handler.myhandler.format=./dirprm/my_template.vm
    gg.handler.myhandler.type=my.custom.GGHandler
    I've verified that I have a valid DsEvent and a DsTransaction with the desired information in by custom handler's transactionCommit method ... and I can even pull out the required data and re-format it there to the desired format so that it looks just like the format that my Velocity template outputs when I'm outputting to a file (as shown in the first properties file).  But shouldn't I somehow  be able to access the Velocity transformation for my DsTransaction in my custom handler?
    Thanks for any assistance / info provided.

    I would have thought it would be possible to use a Velocity template in combination with a custom handler in a Java user exit, but I can't seem to figure out how  to do it, and I'm not finding an example of doing this anywhere in the GoldenGate docs.
    For example, I can create a Velocity template and use it to output transactions in the desired format to a file by using a propeties file that looks something like this:
    gg.handlerlist=myhandler
    gg.handler.myhandler.mode=tx
    gg.handler.myhandler.format=./dirprm/my_template.vm
    gg.handler.myhandler.type=file
    gg.handler.myhandler.file=my_output.txt
    What I'm hoping to do is to have a custom handler, and some how  be able to get to the Velocity formatted transaction data in the "transactionCommit(DsEvent, DsTransaction)" method of my custom extension of AbstractHandler by having a properties file that looks like this (same as the above, except for the type, and no file property ... eg:
    gg.handlerlist=myhandler
    gg.handler.myhandler.mode=tx
    gg.handler.myhandler.format=./dirprm/my_template.vm
    gg.handler.myhandler.type=my.custom.GGHandler
    I've verified that I have a valid DsEvent and a DsTransaction with the desired information in by custom handler's transactionCommit method ... and I can even pull out the required data and re-format it there to the desired format so that it looks just like the format that my Velocity template outputs when I'm outputting to a file (as shown in the first properties file).  But shouldn't I somehow  be able to access the Velocity transformation for my DsTransaction in my custom handler?
    Thanks for any assistance / info provided.

  • Using Tiscali Webmail with Firefox 6. If I try and delete an email the Ok and Cancel buttons are disabled and nothing happens, have to use F5 to take me back. IE8 works so is this a compatibility issue?

    Using Tiscali Webmail with Firefox 6. If I try and delete an email the Ok and Cancel buttons are disabled and nothing happens, have to use F5 to take me back. IE8 works so is this a compatibility issue?

    It appears OP solved the problem: [/questions/874744]

  • Custom Buttons In Template Issue - Arrgh!

    Hi,
    I created a custom button in Photoshop, using the layer method specified in grayscale. I then created a custom template with six of these buttons. Then I imported a movie with embedded chapter indexes. When I drag this movie to an empty menu window and select my custom template for chapter index creation, the individual chapter video frames do not appear in the buttons, even though the text of these chapters do. The mask for the asset is set to white. If I drag an asset to the buttons, everything looks ok. What gives?.

    I found a solution. I picked an Apple (heh) motion button and created a menu template with that button. Then I dragged my custom shape over each motion button and selected Set Shape. That created the motion buttons with my desired shape. I had to adjust the size and position of the new buttons, but at least it worked. I might also have changed the buttons to drop zones without all this work, but that's for another time.

  • Custom parameters in URL with BexWeb (WAD/Web template)

    Hello all,
    I've been reading a lot in this forum, but I haven't been able to do what I want to do.
    I want to insert a custom parameter in the URL as we made with BW 3.5, and then read it.
    I finally think it's something about the command SET_VARIABLES_STATE, but I cannon get it work.
    In the template I have only been able to insert commands under the Web Template element (either before first display and before first rendereing, both with the same results). I've also tried several types of commands.
    The XHTML generated is as follows:
                    <bi:WEB_TEMPLATE_ACTIONS type="COMPOSITE" >
                        <bi:ACTION_BEFORE_FIRST_RENDERING type="COMPOSITE" >
                            <bi:INSTRUCTION >
                                <bi:SET_VARIABLES_STATE >
                                    <bi:VARIABLE_VALUES type="ORDEREDLIST" >
                                        <bi:VARIABLE_VALUE type="COMPOSITE" index="1" >
                                            <bi:VARIABLE value="ZSESION" text="ZSESION"></bi:VARIABLE>
                                            <bi:VARIABLE_TYPE type="CHOICE" value="VARIABLE_INPUT_STRING" >
                                                <bi:VARIABLE_INPUT_STRING value="ZSESION"></bi:VARIABLE_INPUT_STRING>
                                            </bi:VARIABLE_TYPE>
                                        </bi:VARIABLE_VALUE>
                                        <bi:VARIABLE_VALUE type="COMPOSITE" index="2" >
                                            <bi:VARIABLE value="ZSESION2" text="ZSESION2"></bi:VARIABLE>
                                            <bi:VARIABLE_TYPE type="CHOICE" value="VALUE_SET_VARIABLE" >
                                                <bi:VALUE_SET_VARIABLE value="ZSESION2"></bi:VALUE_SET_VARIABLE>
                                            </bi:VARIABLE_TYPE>
                                        </bi:VARIABLE_VALUE>
                                        <bi:VARIABLE_VALUE type="COMPOSITE" index="3" >
                                            <bi:VARIABLE value="ZSESION3" text="ZSESION3"></bi:VARIABLE>
                                            <bi:VARIABLE_TYPE type="CHOICE" value="TEXT_VARIABLE" >
                                                <bi:TEXT_VARIABLE value="ZSESION3"></bi:TEXT_VARIABLE>
                                            </bi:VARIABLE_TYPE>
                                        </bi:VARIABLE_VALUE>
                                    </bi:VARIABLE_VALUES>
                                </bi:SET_VARIABLES_STATE>
                            </bi:INSTRUCTION>
                        </bi:ACTION_BEFORE_FIRST_RENDERING>
                    </bi:WEB_TEMPLATE_ACTIONS>
    I pass it in the URL this way:
    &BI_COMMAND_1-VARIABLE_VALUES-VARIABLE_VALUE_1-VARIABLE_TYPE=VARIABLE_INPUT_STRING&BI_COMMAND_1-VARIABLE_VALUES-VARIABLE_VALUE_1-VARIABLE_TYPE-VARIABLE_INPUT_STRING=010/2010&BI_COMMAND_1-VARIABLE_VALUES-VARIABLE_VALUE_1-VARIABLE=ZSESION
    Also, I want to read it using the ABAP interface IF_BICS_CONS_WEBITEM_CUST_EXIT, method EXECUTE.
    I wonder if it's possible that, once the command parameter works, that the value of my parameters arrives here in the I_XML in parameter.
    I've also read about standard class CL_RSWR_SERVICES, but I don't really want to debug a std class and even less to enhace it ...
    PD: This variable ZSESION does not exist in any query, and we don't want it to exist, as it's only necessary for integration in the intranet.
    Thanks to all,
    Rafa
    Edited by: Rafael LLabrés Pérez on Sep 28, 2011 3:54 PM

    Hi,
    It is possible in 7.0, but unfortunately it is a lot more complicated than i 3.x. There are quite a few examples here:
    http://help.sap.com/saphelp_nw70/helpdata/en/43/ef05462480025ae10000000a1553f7/content.htm
    I used it in a case where I wanted to embed a Web template in a BPS application and pass characteristic filters from the BPS application to the web template - similar to your requirements. Basically you need the following just to restrict one characteristic :o(
    &BI_COMMAND_1-BI_COMMAND_TYPE=SET_SELECTION_STATE
    &BI_COMMAND_1-TARGET_DATA_PROVIDER_REF_LIST-TARGET_DATA_PROVIDER_REF_1=DP_1
    &BI_COMMAND_1-CHARACTERISTICS_SELECTIONS-CHARACTERISTIC_SELECTIONS_1-SELECTIONS-SELECTION_1=SELECTION_INPUT_STRING
    &BI_COMMAND_1-CHARACTERISTICS_SELECTIONS-CHARACTERISTIC_SELECTIONS_1-SELECTIONS-SELECTION_1-SELECTION_INPUT_STRING=PDS06
    &BI_COMMAND_1-CHARACTERISTICS_SELECTIONS-CHARACTERISTIC_SELECTIONS_1-CHARACTERISTIC=0D_PH2
    I could only get it to work with one characteristic and I suspect, that the reason is that the URL simply gets to long (very quickly). You have to repeat the above for every characterstic you want to use :o(
    Hth,
    Jacob

  • Custom button in alv and disabling all buttons in application tool bar

    Experts,
    Could you please  help me for the below requirements.
    1). How to disable all the buttons (like sorting, print, find, set filter...etc.) in tool bar using oops?
    2). Where can I add my custom download button in alv report using oops?
    Thanks in advance...
    Sridhar..

    Step1:
    Create on local class
    Class <LCL_EVENT_RECEIVER> Definition
    Define the below public methods.
    Method Name     HANDLE_TOOLBAR
    Event Name     TOOLBAR
    Event Class     CL_GUI_ALV_GRID
    Importing     E_OBJECT, E_INTERACTIVE
    Method Name     HANDLE_USER_COMMAND
    Event Name     USER_COMMAND
    Event Class     CL_GUI_ALV_GRID
    Importing     E_UCOMM
    Class <LCL_EVENT_RECEIVER> Implementation 
    .     Method HANDLE_TOOLBAR
         Declare the structure <LS_TOOLBAR> of structure type STB_BUTTON
         Append the button information as given below into table E_OBJECT->MT_TOOLBAR to         display the custom button on ALV grid.
                               LS_TOOLBAR-FUNCTION = u2018DOWNu2019
                         LS_TOOLBAR-QUICKINFO = u2018downloadu2019
                         LS_TOOLBAR-TEXT = u2018downloadu2019
         Method HANDLE_USER_COMMAND
    In this method if E_UCOMM = u2018DOWNu2019 write your logic.
    Step2:
    1.     To excluding the ALV grid buttons, fill the <LT_EXC> with function code CL_GUI_ALV_GRID=>MC_FC_EXCL_ALL
    2.     To generate the ALV Grid, call the method SET_TABLE_FOR_FIRST_DISPLAY
    Class     CL_GUI_ALV_GRID
    Method Name     SET_TABLE_FOR_FIRST_DISPLAY
    Exporting     
    I_STRUCTURE_NAME      ZDS_CM_EXT_SEL
    LS_LAYOUT                    <LS_LAYOUT>
    IT_TOOLBAR_EXCLUDING     <LT_EXC>
    Changing     
    IT_OUTTAB                    <GT_EXT_SEL>
    Create the Instance for class <LCL_EVENT_RECEIVER>
    Class     <LCL_EVENT_RECEIVER>
    Instance Name     <LO_EVENT_FNAME>
    Now set handler  <HANDLE_USER_COMMAND> and <HANDLE_TOOLBAR_FNAME> events using instance <LO_EVENT_FNAME>
    Call method 'SET_TOOLBAR_INTERACTIVE' to raise event TOOLBAR
    Class     CL_GUI_ALV_GRID
    Instance Name     <GO_GRID>
    Method Name     SET_TOOLBAR_INTERACTIVE

  • Need for a Datagrid with variableRowHeight="true" and custom Item Renderer to display exact rows

    Hi again, developers:
    I'm in a search of a datagrid  with certain characteristics:
         - variableRowHeight = "true"
         - only one column
         - each row must have a custom item renderer with possibly different heights, and a fixed width
         - the datagrid must show always every item in the data provider with no vertical scroll bars, what means that the datagrid height must have always the exact height sum of all the item renderers it is displaying.
         - and no extra empty rows must appear in the last positions of the datagrid
    The last two requirements are something difficult to achieve... for some reason, empty rows appear at the last positions of the datagrid. I post what i've managed to get:
    <mx:Script>
         <![CDATA[
         private function resize():void
                    if (dg.dataProvider)
                        var h:Number = dg.measureHeightOfItems( -1, dg.dataProvider.length);
                        dg.height = h;
         ]]>
    </mx:Script>
    <mx:DataGrid id="dg" width="530" horizontalCenter="0" verticalScrollPolicy="off"
            dataProvider="{dp}"
            wordWrap="true" variableRowHeight="true" showHeaders="false" dataChange="resize()" height="{dg.measureHeightOfItems(-1,dg.dataProvider.length)}" click="Alert.show(dg.rowCount.toString());">
            <mx:columns>
                <mx:DataGridColumn headerText="ID" width="50">
                    <mx:itemRenderer>
                        <mx:Component>
                            <mx:TextArea height="{Math.random()*100}" wordWrap="true" backgroundColor="{Math.random() * 16777216}" paddingTop="0" paddingBottom="0"/>
                        </mx:Component>
                    </mx:itemRenderer>
                </mx:DataGridColumn>
            </mx:columns>
        </mx:DataGrid>

    Thanks Harui, but it doesn't help. If the border is set it will help, but the very big problem is the empty rows that appear at the end of the datagrid... I can't find a way of measuring correctly the height of the itemRenderers!
    I'll update this thread if I manage to do it.

  • Custom button skin with scaleGrid 9 slice image does not appear in Design Mode

    So in a custom button skin I have a nine sliced image, and then throw that onto an MXML page. In design view, I cannot get the component to show the image that I've thrown on it. Unless I do a hack on the MXML page by adding the image in it's scaleGrid form to the page somewhere. Then it seems to act as like a preloader for the image so it actually displays. But I don't want to do this hack on every page that uses this component. Is there a work around?
    Here's the button skin:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
                        xmlns:s="library://ns.adobe.com/flex/spark"
                        width.disabled="296" height.disabled="73">
    <!-- host component -->
    <fx:Metadata>
                        [HostComponent("spark.components.Button")]
                        [Embed('assets/art/shared/[email protected]', scaleGridTop=20, scaleGridBottom=85, scaleGridLeft=40, scaleGridRight=60)]
    </fx:Metadata>
    <!-- states -->
    <s:states>
                        <s:State name="disabled" />
                        <s:State name="down" />
                        <s:State name="over" />
                        <s:State name="up" />
    </s:states>
              <s:Group width="100%" height="100%" >
      <s:Image width="100%" height="100%" smooth="true" source="@Embed('assets/art/shared/[email protected]', scaleGridTop=20, scaleGridBottom=85, scaleGridLeft=40, scaleGridRight=60)"/>
    </s:Group>
    <!-- text -->
              <s:Label id="labelDisplay" left="10" right="10" top="2" bottom="2" horizontalCenter="0"
                                   maxDisplayedLines="1" textAlign="center" verticalAlign="middle" verticalCenter="1"
                                   color="#FFFFFF" >
      <s:filters>
                                  <s:DropShadowFilter distance="0" angle="90" color="0x000000" alpha="1" blurX="2" blurY="2" strength="16" quality="3" />
      </s:filters>
    </s:Label>
    </s:Skin>
    And then I throw that button into an MXML page. The image doesn't show up in design view.
    <s:Button x="330" y="94" width="134" height="57" label="Button" skinClass="features.shared.NineSliceButtonSkin" />
    This hack, fixes the button! And all other buttons that use that skin.
    <s:Image width="100%" height="100%" smooth="true" source="@Embed('assets/art/shared/[email protected]', scaleGridTop=20, scaleGridBottom=85, scaleGridLeft=40, scaleGridRight=60)"/>
    <s:Button x="330" y="94" width="134" height="57" label="Button" skinClass="features.shared.NineSliceButtonSkin" />

    Looking for an answer too!

  • How to disable the custom button on alv?

    Hi All,
                       i created a ALV Report .I created a Custom Button on ALV.Based on the input value i need to enable/disable  that Button.
    How can i achieve?And what are the methods i need to code?
    Regards
    Ravi

    Hi Ravi,
       You create the button like this:
    Data: mr_functions type ref to IF_SALV_WD_FUNCTION_SETTINGS,
             mr_button_func type ref to CL_SALV_WD_FUNCTION
      mr_functions ?=  mr_alv_model.
      CALL METHOD mr_functions->create_function
        EXPORTING
          id    = '<<Button Id>>'
        RECEIVING
          value = mr_button_func.
      CREATE OBJECT mr_button.
      mr_button->set_text( 'some text' ).
      mr_button_func->set_editor( mr_button ).
    to sent enable/disable
    mr_button->set_enabled(abap_false).
    hope this will serve your purpose.
    Regards,
    Ritwik.

  • Custom sendemail in sharepoint 2013 designer workflow using dictionary object with email template from list

    I  am looking for custom sendemail in sharepoint 2013 designer workflow using dictionary object with email template from list
    MCTS Sharepoint 2010, MCAD dotnet, MCPDEA, SharePoint Lead

    Hi Greetings.
    pls check if it helps you.
    http://msdn.microsoft.com/en-us/library/office/jj554504(v=office.15).aspx
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Custom validation is disabling submit button

    Hi there,
    I am using the update/insert feature within ADDT, but wanted to use my own validation using JavaScript. Everything works fine, the validation pop-up works etc, but the submit button is disabled. I'm guess that the transaction has started with the ADDT, but the javascript has stopped it. How can I get around this? any suggestions welcome...
    Thanks in advance...

    Hi,
    Have you tried different browsers to double check. I remember a couple months ago I was helping someone with a similar problem, it worked in one browser fine but not the other so we had to rewrite the code. Initially the code looked fine but just didnt work in IE.

  • Performance decrease with custom cell renderer

    Hi,
    Finally, I have my cell renderer working fine (it was simpler than I thought). Anyway, I'm suspecting something is not working quite well yet. When I try to reorder my colums (by dragging them) they move like slow motion. If I don't register my custom cell renderer, I can move my columns fine. Next is the code of my custom renderer.
    class PriorityRenderer extends DefaultTableCellRenderer {   
      public Component getTableCellRendererComponent(
      JTable table, Object value,     boolean isSelected,
      boolean hasFocus, int row, int column) {              
        if(value instanceof coloredValue) {
        coloredValue cv = (coloredValue)value;
        if(isSelected) this.setBackground(table.getSelectionBackground());
        else this.setBackground(cv.getbkColor());
        this.setForeground(cv.gettxColor());
        this.setText(value.toString());
        this.setOpaque(true);
        return this;
    }All the cells of my JTable are "coloredValue"s. This is a little class with a String, two colors and some getter methods.
    Can anyone giveme a hint ?
    Thanks!!

    OK! Now the performance problem is gone!! (I don't know why, I didn't touch a thing)
    Thanks anyway

  • Help with JTreeTable custom cell renderer!

    Hi.
    I've followed diligently the complete TreeTable2 example found on the Sun site. http://java.sun.com/products/jfc/tsc/articles/treetable2/
    What I'm trying to do is to add alternate-row shading on the Column(0) of the JTreeTable where the Column class is "TreeTableModel".
    so, from the example, I've added the following setCellRenderer declaration to TreeTableExample2.java:
         protected JTreeTable createTreeTable() {
              JTreeTable       treeTable = new JTreeTable(model);
              treeTable.getColumnModel().getColumn(1).setCellRenderer
              (new IndicatorRenderer());
              treeTable.getColumnModel().getColumn(0).setCellRenderer
              (new MyTableCellRenderer());Then, I subclass DefaultTableCellRenderer as shown below, in a new class called "MyTableCellRenderer"
    import java.awt.Color;
    import java.awt.Component;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableCellRenderer;
    import javax.swing.table.TableCellRenderer;
    public class MyTableCellRenderer extends DefaultTableCellRenderer implements TableCellRenderer
         private static final long serialVersionUID = 1L;
         public MyTableCellRenderer() {
         public Component getTableCellRendererComponent(JTable jtable, Object obj, boolean isSelected, boolean hasFocus, int i, int j)
              if (i % 2 == 0 && !isSelected) {
                   this.setBackground(new Color(214,226,255));
                   this.setForeground(Color.BLACK);
              } else if (isSelected)
                   this.setBackground(new Color(204, 204, 255));
              else {
                   this.setBackground(Color.white);
              //if (obj != null)
              this.setValue(obj.toString());
              System.out.println("obj: " + obj.toString());
              System.out.println("obj type: " + obj.getClass().getName());
              return ((Component) (this));
    }I've been pulling out whatever few hairs I have left in my sparse scalp to get this working, but it's looking grim thus far.
    Here are links to screenshots of my progress, or lack thereof:
    Original Working TreeTable II
    http://www.pharmalytix.com/original_treetable.jpg
    My Not-working Tree Table II w/ Custom Cell Renderer
    http://www.pharmalytix.com/customtablecellrenderer_treetable.jpg
    thanks again - !!

    phew! finally got this sucker working. I had to retrieve the default rendererer of my TreeTable's TreeTableModel class column, which is the JTree and then, in its component-form, start mucking about with its stylings. The real black-hole of progress was caused by my brain imploding from not being able to understand that a "Component" was what represented the "thing" whose behaviour I wanted to alter, be it a Jtree node or Jtable cell.
              treeTable.getColumnModel().getColumn(0).setCellRenderer(new TableCellRenderer() {
                   public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
                        Component comp = treeTable.getDefaultRenderer(TreeTableModel.class).getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col);
                        if (row % 2 == 0 && !isSelected) {
                             comp.setBackground(new Color(214,226,255));
                             comp.setForeground(Color.BLACK);
                        } else
                             if (isSelected)
                                  comp.setBackground(new Color(204, 204, 255));
                             else {
                                  comp.setBackground(Color.white);
                        return comp;
              });In all of its ravishing glory:
    http://www.pharmalytix.com/alternateshading_treetable.jpg
    Edited by: DataHog on Nov 6, 2007 10:21 AM

  • Using social media share codes with custom buttons

    Is there a way to use custom buttons/icons for social media share, like, etc..? I have tried inserting the html with no luck. The canned social widgets don't really match the look of the site I am designing.

    Facebook doesn't allow changing that. Refer to their Guidelines with Do's and Don'ts here - https://www.facebookbrand.com/guidelines?asset=5&media=1,2,3&platform=
    Thanks,
    Vinayak

Maybe you are looking for

  • Unable to update

    itunes is telling me that i have more music than the amount that my ipod can hold. i have a mini which is kind of old but it still works good. so i deleted the playlist that itunes made for me since my ipod is too full because i wanted to make a new

  • How to create an LOV based on a dynamic query

    Hi, Can someone tell me how to query a dynamic query for LOV. On my base page I have a dropdown-box (that will show the table names for searching) and is dynamically populated based on users access e.g. if user A logs in he may see 5 values (these va

  • Return orders

    Hi BI Gurus, I have to write a report for return delivery process. What they do is the users will create a return order with reference to original sales order, delivery with reference to return order and credit memo will be automatically once the del

  • Override filename in cfmail

    Hello all, Is it possible to overwrite the name of an attachment in cfmail using a certain cfmailparam property or something? The files are stored on disk with an unique identifier as filename, but as soon as I would like to send them via cfmail the

  • Transfer from windows to mac

    i recently bought a macbook and i tried to connect my ipod to my macbook but it freezed and won't do anything. i previously used windows xp to update my ipod. any clue?