Generating script tag from Custom JSF Tag

Hi,
I am new to JSF Custom Tags. I developed a Custom tag. It's quite a fun to make your own custom tags . Now I have to use some javascript for my custom components. The inline javascript calls are no issue for me. But I want my javascript be embedded in a <script> tag automatically. So that I don't have to explicitly add my javascript into <script> tag, instead, it is automatically included in the page where my tags are being used. How can this be achieved?
Regards,
Kashif

Anchors don't have a type="submit". You should be basing this on an h:commandLink. In fact you could probably rewrite it all as an XML tag that just generates an h:commandLink.

Similar Messages

  • JSF tag inside another JSF tag

    Hi,
    Note: It's a bit of a long post but I will try to cut to the point without leaving behind any pertinent details.
    I've created some simple custom JSF tags in the past. The tags usually consisted of one or two attributes that would be beans. The tags would then print out the data for those beans or process them and then output the results.
    What I am trying to do now is a bit more complicated for me. I have a JSP page with a scriplet on it. It iterates over a bean containing a list of items. The loop adds those items to an HTML select menu one at a time. The outline of the code looks similar to this,
    <% extract data List from the bean and store it in variable called dataList %>
    <select>
    <%
      for (int i=0; i<dataList.size(); i++;){
        ListItem item = dataList.get(i);
        String name = item.getName();
        String value = item.getValue();
    %>
    <option value="<%=value%>">
      <%=name%>
    </option>
    <%}%>
    </select>
    <h:commandButton id="gobtn" action="go_to_page" actionListener="#{action.fetch}" value="Go"/>What I want to do is take all the above code and put it into a custom JSF tag. This tag would contain all the scriplet code, output the HTML code and also the commandButton code at the end.
    All of that is pretty easy except for the commandButton part. I am not sure how to output a commandButton from a custom JSF tag. How do I pass it the action.fetch part for the actionListener attribute? Can I create a commandButton object in my custom JSF tag and pass it this information?
    I've followed a tutorial at this site in the past but it doesn't go into too much detail
    http://www.exadel.com/tutorial/jsf/jsftutorial-customcomponents.html
    Any help is appreciated,
    Nick

    I guess I missed some information. The dataList in the bean is stored in a HashMap. So some work has to be done with the bean before hand to determine what list to pull out and then "massage" it a bit for viewer consumption. This is not easily accomplished with the standard JSF html tags, hence my going with a custom tag approach.
    Processing this bean and getting a list from the Hashmap in the bean before displaying it is easy, so is outputting the HTML. The hard part is rendering the commandButton with all the attributes I listed previously.
    Is there a way in general to have other JSF tags nested inside a custom JSF tag?

  • UIX replacment for isUserInRole tag from the “Request Tag Library,”

    Is there a UIX replacement for the isUserInRole which is provided by the “Request Tag Library”?
    This tag checks if the user has the correct security roles.
    thanks
    Marcel

    Is there a UIX replacement for the isUserInRole which is provided by the “Request Tag Library”?
    This tag checks if the user has the correct security roles.
    thanks
    Marcel

  • How to use value from Custom Select tag

    Hi,
    I have made a custom tag for html element select. It is a very basic tag with the selection of one vaule. I am able to populate the list using custom tag in JSP but i am not able to optain the value from that. Kindly see my jsp code.
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Expenses Report</title>
    </head>
    <body>
    <center>
    <table summary="layout">
    <tr>
    <td>Month:</td>
    <td>
    <tt:Select name="month" from="${ExpensesDBO}"/>
    </td>
    </tr>
    </table>
    <c:if test="${fn:length(param.month) > 0}">
    <table summary="layout" border="1">
    <tr>
    <td align="center">Year</td>
    <td align="center">Month</td>
    <td align="center">Shopping</td>
    <td align="center">Groceries</td>
    <td align="center">Fixed Expenses</td>
    <td align="center">Transportation</td>
    </tr>
    <tt:Expenses var="exp" username="${sessionScope.user}" from="${ExpensesDBO}">
    <tr>
    <td>${exp.year}</td>
    <td>${exp.month}</td>
    <td>${exp.shopping}</td>
    <td>${exp.groceries}</td>
    <td>${exp.fixedExpenses}</td>
    <td>${exp.transportation}</td>
    </tr>
    </tt:Expenses>
    </table>
    </c:if>
    </center>
    </body>
    </html>
    Basically based on the selected value I want to show the same page with the details including page with the default value in select list.
    I have made a generic select custom tag to be used within the application.
    Regards,
    Rahul.

    If both tables come from the same data source, join the two tables in one data set rather than two as shown. If they are from different data sources, use a 'join data set'

  • Custom JSF tag not working HELP!!!!

    We have a custom tag to display the list of attachments for a a selected entity. So for example if there are entities A, B, C...each entity can have none or 1 or more attachments. When you go to the details page you see the list of attachments if any and an image against it that can be clicked to delete the attachment.
    Here is the tag:
    <at:attachmentTable value="#{Entity.attachmentList}" remove="#{Entity.removeAttachment}" />
    Here is the renderer code for the delete the attachment part of the tag:
    private void writeRemove(UIComponent component, FacesContext ctx, ResponseWriter writer, String clientId, Attachment attachment, String parentId) throws IOException {
              writer.startElement("td", component);
              writer.startElement("a", component);
              writer.writeAttribute("href", "#", null);
              writer.writeAttribute("onmousedown", "confirmationDelete(this, 'attachment');", null);
              String encoding = "if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('"+ parentId + "'),{'" + clientId + "':'" + clientId + "','attachmentId':'" + attachment.getId().toString() +"'},'');}return false";
              writer.writeAttribute("onclick",encoding, null);
              writer.writeAttribute("type", "submit", null);
              writer.startElement("img", component);
              writer.writeAttribute("src", "/acw/images/removeline.gif", null);
              writer.writeAttribute("alt", "", null);
              writer.endElement("img");
              writer.endElement("a");
              writer.endElement("td");
    Here is the setProperties method for the tag:
         protected void setProperties(UIComponent component) {
              FacesContext context = FacesContext.getCurrentInstance();
              super.setProperties(component);
              setProperty(component, "value", value);
              setProperty(component, "parameterValue", parameterValue);
              setProperty(component, "parameterName", parameterName);
              if (remove != null && UIComponentTag.isValueReference(remove)) {
                   MethodBinding method = FacesContext.getCurrentInstance().getApplication().createMethodBinding(remove, new Class[] {});
                   UICommand command = (UICommand)component;
                   command.setAction(method);
    Here is how the tag renders as an <a> html tag:
    a href="#" onmousedown="confirmationDelete(this, 'attachment');" onclick="if(typeof jsfcljs == 'function'){jsfcljs(document.getElementById('entity'),{'entity:j_id_jsp_1417973014_25':'entity:j_id_jsp_1417973014_25','attachmentId':'10326'},'');}return false" type="submit"><img src="/images/removeline.gif" alt="" /></a>
    Here is what is heppening:
    When you click on the image to delete the attachment, the control somehow nevers goes to the removeAttachement method in the backing bean. As you can see in the tag above (remove="#{Entity.removeAttachment}" ).
    I have tried everything and at this point am not able to see what is going worng. Anyone who can see the obvious that I am missing please please do point it to me. I am sort of desperate for a solution....
    Thanks.
    TD

    Anchors don't have a type="submit". You should be basing this on an h:commandLink. In fact you could probably rewrite it all as an XML tag that just generates an h:commandLink.

  • Changing Date Time Original Tag from Date Created Tag

    Hi,
    I need to change programmatically the "Date Time Orignal" tag by copying the "Date Created" Tag so that Media Encoder preserves the date during encoding. I can do this by hand without a problem in Bridget 5.5 but would like to automate it. Can I do this with a script?
    Thanks
    Axel

    I have been als been plagued by LR displaying the capture time to be, say 3 AM (03:00), when I know I took the picture at 1 PM (13:00). I decided to try and see why this happens. With the help of Phil Harvey's exiftool, I can see that my Canon cameras embed the time into the EXIF data without any time zone information i.e.: Date/Time Taken = 2008:04:02 16:09:23.
    Here is what I found:
    If the image is now edited with Bridge, the information is changed to: Date/Time Taken = 2008:04:02 16:09:23-08:00 (time zone of the editing computer for the date the image was made. In this case the date was before daylight savings time started.)
    When edited with GeoSetter (good for adding GPS information) the information is changed to: Date/Time Taken = 2008:04:02 16:09:23+02:00 (time zone for Cairo where the picture was taken.)
    Lastly edited with LR, the information is changed to: Date/Time Taken = 2008:04:02 16:09:23-08:00
    When the above images are viewed in LR, using PDT, they display the time as 17:09:23 except for the image tagged with the Cairo time, which displays 07:09:23. If the computer's time zone is changed the displayed time changes accordingly.
    If the images are displayed with Photoshop CS3 all the times are correctly displayed as 16:09:23 as one would expect.
    It appears that the factoring in of the time zone into the displayed time was a conscious decision by the Adobe designers. A decision that several of us are not happy with.

  • Using TAG Attributes within JSF Tags

    I'm using some .tag files for templating purposes. I'm using two tag attributes via <@% attribute %> directive. How can i access this attribute to do something like follows.
    <%@ tag display-name="Area de Trabajo" language="java" %>
    <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <%@ taglib prefix="t" uri="http://myfaces.apache.org/tomahawk"%>
    <%@ attribute name="title" required="true"%>
    <%@ attribute name="location" %>
    <t:div styleClass="zonaArea#{(not empty location) ? location : 'Global'}">
      <h:panelGrid columns="1">
        <h:outputText value="#{title}" />
      </h:panelGrid>
      <jsp:doBody />
    </t:div>

    Hola Alberto.
    Any luck? Did you worked that around?
    I'm just trying to do the same thing...
    Tried to do something like:
    <%@attribute name="enabled" type="java.lang.String" %>
    <h:outputText value="test: #{requestScope['enabled']}" style="font-weight: bold;" /> to no avail...
    Let me know, please!
    Hi,
    Manrico

  • HT201724 how do you romove the sound check normalization tag from your id3 tags?

    just curious if anyone knows how to do this. I know if you just uncheck sound check in itunes it won't read the tags, but having issues with other players reading them, so I want to remove them. Anyone?

    turingtest2 wrote:
    Hi,
    I've written a script called UpdateTagInfo which should do the trick for you. Just select a bunch of tracks or an appropriate playlist and call the script. It will process each track, updating the tags if they've been changed externally. When complete it will tell you how many tracks were processed & how many were updated.
    More scripts at http://samsoft.org.uk/iTunes/scripts.asp
    tt2
    This is great! Thanks for posting and letting us know...
    Sandy

  • XQuery for making two tags from a single tag

    Hi All,
    I am using OSB 11g. I am getting an XML like this:
    <DOC>
    <INFO>
    <ATTRIBUTE ID="name">
    <VALUE>ABCD</VALUE>
    </ATTRIBUTE>
    <!--Optional-->
    <ATTRIBUTE ID="date">
    <VALUE>
    29/09/09
    19/09/11
    </VALUE>
    </ATTRIBUTE>
    <!--Optional-->
    <ATTRIBUTE ID="accNo">
    <VALUE>823748923987</VALUE>
    </ATTRIBUTE>
    <!--Optional-->
    <ATTRIBUTE ID="address">
    <VALUE>XYZW</VALUE>
    </ATTRIBUTE>
    </INFO>
    </DOC>
    Only when ID="date", I want to change the ATTRIBUTE tag as
    <ATTRIBUTE ID="date">
    <VALUE>29/09/09</VALUE>
    <VALUE>19/09/11</VALUE>
    </ATTRIBUTE>
    Is there any XQuery to do this in OSB?
    Please help!!
    Thanks in advance!!
    Regards,
    Karthik

    Try this:-
    Assign [ <test>... ]
    <test> <value></value> <value></value> </test>
    to [ finalValueDate ]
    For Each [ attribute ] in [ ./*:DOC/*:INFO/... ]
    ./*:DOC/*:INFO/*:ATTRIBUTE
    of [ body ]
    Indexed by [ undefined Variable ] with total count in [ undefined Variable ]
    Do (
         If ([ $attribute/@ID ... ]
    $attribute/@ID = "date"
         then (      
    Assign [ fn:normalize-sp... ]
    fn:normalize-space($attribute/*:VALUE/text())
    to [ date ]
    Replace [ node contents ] of [ ./*[1] ]
    ./*[1]
    in [ finalValueDate ] with [ fn:substring($d... ]
    fn:substring($date, 1, 8)
    Replace [ node contents ] of [ ./*[2] ]
    ./*[2]
    in [ finalValueDate ] with [ fn:substring($d... ]
    fn:substring($date, 10, 8)
    Replace [ entire node ] of [ .//ATTRIBUTE[@ID="date"]]
    .//ATTRIBUTE[@ID="date"]
    in [ body ] with [ <ATTRIBUTE>... ]
    <ATTRIBUTE> <VALUE> {$finalValueDate/*[1]/text()}</VALUE> <VALUE> {$finalValueDate/*[2]/text()}</VALUE> </ATTRIBUTE>
    This worked for me. I got the following response:
         <DOC>
         <INFO>
         <ATTRIBUTE      ID="name">
         <VALUE>ABCD</VALUE>
         </ATTRIBUTE>
         <!--Optional-->
         <ATTRIBUTE>
         <VALUE>29/09/09</VALUE>
         <VALUE>19/09/11</VALUE>
         </ATTRIBUTE>
         <!--Optional-->
         <ATTRIBUTE      ID="accNo">
         <VALUE>823748923987</VALUE>
         </ATTRIBUTE>
         <!--Optional-->
         <ATTRIBUTE      ID="address">
         <VALUE>XYZW</VALUE>
         </ATTRIBUTE>
         </INFO>
         </DOC>

  • How do you retrieve child tags from a parent tag in a tree structure and build an array from it?

    Is there a property node somewhere that can retrieve the tags of all the children of an "active" parent tag in a tree structure? If I click on the parent tag, I want to be able to show what child tags are under that parent tag.

    There is not a property or method that I have been able to find, however I wrote this VI that given a parent tag returns all the children.
    Evan Collier
    Attachments:
    Get_1_Lv_of_children.vi ‏59 KB

  • Custom taglib: tags not rendered in visual editor

    Hi!
    I have created a custom tag library with jsf tags. I have created one tag that extends the CoreSelectOneChoiceTag. When I drag this tag on a page, at runtime it works completely as desired.
    Only, in the visual editor the tag is invisible. With the tag library properties I have specified that the tags should be executed. In the source and structure windows the tags is visible (of course).
    What influences how a tag is rendered in the visual editor, and what content is rendered?
    Jeroen van Veldhuizen

    I know there's a recent release with a visual editor problem, but I'm not sure which one it is. This thread says you need a fresh install? Can you try that?
    Re: ADF Faces tutorial/code sample for data table?

  • Hiding conditional logic using JSF tags

    Hi
    I'm trying to encapsulate some logic which, dependent on a true / false validation, outputs either one component or another containing a value.
    For example...
    when the validation is true, output <h:selectOneMenu... containing all available values with selected value highlighted.
    when the validation is false, output <h:outputText... containing selected value.
    I've tried custom tags but I'm using this to write out very basic tags and I'd prefer to use the JSF HTML tags.
    The only option I can see is to write conditional logic in the JSPs to say:
    if valid = true
    <h:selectOneMenu...
    else
    <h:outputText...
    endif
    ...but this means the developers must do this for every occurrence and the pages contain lots of conditional logic.
    Is there any way to create a custom JSF tag which outputs JSF HTML tags as this seems to be what we want to do?
    Thanks D

    There is no tag for this, but every HTML component has a 'rendered' attribute which accepts a boolean expression. If it's outcome is true, then the component will be rendered, otherwise it will be hidden.
    Here are some basic examples:
    <h:someComponent rendered="#{myBean.booleanValue}" />
    <h:someComponent rendered="#{myBean.intValue > 10}" />
    <h:someComponent rendered="#{myBean.objectValue == null}" />
    <h:someComponent rendered="#{myBean.stringValue != 'someValue'}" />
    <h:someComponent rendered="#{!empty myBean.collectionValue}" />
    <h:someComponent rendered="#{!myBean.booleanValue && myBean.intValue != 0}" />
    <h:someComponent rendered="#{myBean.stringValue == 'oneValue' || myBean.stringValue == 'anotherValue'}" />

  • [JS IDCS5] Create tags from paragraph styles

    Hello,
    I would like to iterating through al the paragraph styles within a document to create there tags from. The tags should have the same name as the paragraph styles. Is that possible and how?
    Regards, Sjoerd

    Hi Phil,
    Absolute beginer here. The script creates tags for the styles outside groups, but for some reason it doesn't create the tags out of the Paragraph Styles in folders.
    I enabled the line below and tried to change the "myPStyle"  for "myAllPStyle" in the following lines, but still nothing. Gives error when reaches the line myDoc.changeText();
    Any hint?
    var myAllPStyle = myDoc.allParagraphStyles; //if you want this enable a line all the folder paragraph styles also consider
    for (i=2; i<myAllPStyle.length; i++){
         var myAllPStyleName = myAllPStyle[i];
         //alert(myPStyleName.name);
         try{
              var myXml = myDoc.xmlTags.add(String(myAllPStyleName.name));
              }catch(e){}
         app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
         app.findTextPreferences.appliedParagraphStyle = myAllPStyleName;
         app.changeTextPreferences.markupTag=myAllPStyle[i].name;
         myDoc.changeText();
         app.findTextPreferences = app.changeTextPreferences = NothingEnum.nothing;
    Also, how can I make it Map the tags with the PStyles by name after with the script?
    Thanks so much
    Hector

  • Building JSF tag using existing Tags

    Hi all
    I wonder if it's possible to create a new JSF tag using existing JSF Tags?
    For example, I have a JSF tag which renders a lable and a textinputfield, let's call it <f:field>
    Now I want to build a new JSF tag, which will re-use the existing tag <f:field>. IS it possible?
    Thanks in advance

    Did you have a chance to look at facelets solution. Facelets provide several approach how to create composition components.
    Sergey : https://ajax4jsf.dev.java.net

  • Custom JSF Component tags ignored after converting to Facelets layout

    I am currently using JDeveloper 10.1.3.3.
    I have a project consisting of .jspx pages. These pages mainly use components from ADF faces core. I also created my own custom JSF component that I use in several of these pages.
    Then, I needed to use Facelets so that I could apply a standard layout to all my .jspx pages. I looked at all the tutorials, and I created a layout.xhtml for my .jspx pages to use. This worked great for my .jspx pages that don't have my custom JSF component.
    Now, when I run my page with my custom component <img:newimage ...etc >
    the tag is ignored and it appears in the page's source as is when it should render as <img.src=...etc>. Attributes of newimage are changed on the page appropriately like width and height, but my component's tag, component, and servlet java files are never accessed.
    How can I fix this? Please help!
    Thanks.

    Hi,
    did you post this issue to the Facelets open source site ? Sounds like an issue with using Facelets
    Frank

Maybe you are looking for

  • Only able to access wireless network through system diagnostics

    I have a Macbook (white, early 2008). Wherever I go my Airpot works fine at connecting, but at home, whenever I try connecting to the wireless network normally (clicking the airport tab, choosing network, etc.), I enter the password, which I know 100

  • Speaker doesn't work

    Help my speaker in my iPhone 5 is not working. Can't hear it ring alert or my music.

  • Solaris 8 (32/64-bit) for Hyperion Essbase OLAP Server Release 6.5.4

    Dear all, Do anyone know the difference between and impact on Solaris 8 (32/64-bit) for Hyperion Essbase OLAP Server Release 6.5.4?Thanks for your help!Regards,Zero Lai

  • Unable IMPORT EXPORT ???

    hi i try to use import from export file or export to export file. i make a job but at the end when i submitt job i have an error : (oracle 10g) ORA-20204: User does not exist: POVAPSYS ORA-06512: na "SYSMAN.MGMT_USER", line 122 ORA-06512: na "SYSMAN.

  • Vertical writing in smartforms

    Hi, I would like to write a vertical text in smartform, is it possible? how? Thanks.