Search Results

Search found 14593 results on 584 pages for 'pat inside'.

Page 38/584 | < Previous Page | 34 35 36 37 38 39 40 41 42 43 44 45  | Next Page >

  • Silverlight 3 - Creating Custom Objects inside a Merged ResourceDictionary

    - by Tony Heupel
    I have custom classes that I currently instantiate within App.xaml as resources. I want to move these custom objects into a Merged ResourceDictionary, where they are used within styles, and keep them close to where they are used. Here's an example of what I want, arbitrarily using fake converter objects, but they could be any custom object... App.xaml (namespace declarations ommitted): <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Merged.xaml" /> </ResourceDictionary.MergedDictionaries> <Style x:Key="SomeStyle" TargetType="SomeControl"> ... </Style> ... </ResourceDictionary> And then in Merged.xaml (namespace declarations omitted): <ResourceDictionary> <cvt:VisibilityToBoolConverter x:Key="BoolToVisibility" Inverted="True"/> <cvt:VisibilityToBoolConverter x:Key="NotBoolToVisibility" Inverted="True" Not="True"/> <Style x:Key="SomethingThatUsesVisibilityToBoolConvertersStyle" TargetType="SomeOtherControl"> .... </Style> </ResourceDictionary> The issue I'm seeing is this: when I create the BoolToVisibility and NotBoolToVisibility objects (as well instantiating other objects that are instances of custom classes I have created) just as part Application.Resources, they are created and all the references work as expected; however, when I move these into a Merged Resource Dictionary (as I have in the sample above), I get a malformed Application exception when the Silverlight application loads. I belive this to be an issue with how objects are instantiated differently in Merged Resource Dictionaries (I belive it is more of a lazy-load approach), but I would expect it to work nonetheless. I am very much able to add Style objects, DataTemplates, ControlTemplates, and the like. But when I want to create instances of custom classes that are named or keyed using Xaml, it works great inside of App.xaml's Application.Resources directly and Application.Resources/ResourceDictionary as well. As soon as they are moved into a merged dictionary, it throws the exception. Is this by design? Any other ideas that work? Thanks in advance...

    Read the article

  • php if clause inside foreach not retrieving data correctly

    - by Mike
    Here's my issue: In my controller, I want to grab user input from a form. I then parse the input, and compare it to database values to ensure I'm grabbing the correct input. I simply want to match the user's answers to the question, grab the user ID, the question ID, and then determine if the answer applies to a multiple choice or checkbox question, or something else. I take those values and insert them into the answer table. Ignore the waiver stuff. I'll test that once I get the answers input correctly. // add answers and waiver consent records try { $answerArray = array(); $waiverArray = array(); // retrieve answers, waiver consents, and the question ID's from form object foreach ($formData as $key => $value) { $parts = explode("_", $key); if ($parts[0] == 'question') { array_push($answerArray, $value); } if ($parts[0] == 'waiverTitle') { array_push($waiverArray, $value); } } $questions = new Model_DbTable_Questions(); $questionResults = $questions->getQuestionResults($session->idEvent); foreach ( $questionResults as $qr ) { if ($qr ['questionType'] == 'multipleChoice' || $qr ['questionType'] == 'checkBox') { foreach ( $answerArray as $aa ) { $answerData = $answers->addAnswer ( $lastUserID, $qr ['idQuestion'], null, $aa ); echo count ( $answerData ) . ', ' . $qr ['questionType'] . ', ' . $aa . '<br />'; } } else { foreach ( $answerArray as $aa ) { $answerData = $answers->addAnswer ( $lastUserID, $qr ['idQuestion'], $aa, null ); echo count ( $answerData ) . ', ' . $qr ['questionType'] . ', ' . $aa . '<br />'; } } } } catch (Zend_Db_Statement_Exception $e) { $e->getMessage(); throw $e; } From my test data, I expect to get 2 records that match the multiple choice and checkbox criteria, and 1 record for text in the ELSE clause like this: 3, checkbox, 1 3, multipleChoice, 1 3, text, question_2 What I get is a 3x3 Cartesian product, 3 question elements each with the 3 possible answers like this output from the echo statements: 4, checkBox, 1 4, checkBox, 1 4, checkBox, question_2 4, multipleChoice, 1 4, multipleChoice, 1 4, multipleChoice, question_2 4, text, 1 4, text, 1 4, text, question_2 I've tried placing the IF clause inside the inner foreach, but I get the same results. I've been staring at this problem for way too long and cannot see what I'm doing wrong. Your kind assistance would be greatly appreciated. Please let me know if my request requires more clarification.

    Read the article

  • create text inside a rectangle using inkscape

    - by mr calendar
    I've put some text inside a rectangle using inkscape so the tree is like <svg:rect><svg:text><svg:tspan>text.... The problem is, I can't see the text. I've tried fiddling with the opacity of the rect to no avail. There should be a way of doing this from the UI? Edit example as requested <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- Created with Inkscape (http://www.inkscape.org/) --> <svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="184.25197" height="262.20471" id="svg2" sodipodi:version="0.32" inkscape:version="0.46" version="1.0" sodipodi:docname="ex1.svg" inkscape:output_extension="org.inkscape.output.svg.inkscape"> <defs id="defs4"> <inkscape:perspective sodipodi:type="inkscape:persp3d" inkscape:vp_x="0 : 526.18109 : 1" inkscape:vp_y="0 : 1000 : 0" inkscape:vp_z="744.09448 : 526.18109 : 1" inkscape:persp3d-origin="372.04724 : 350.78739 : 1" id="perspective10" /> </defs> <sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" gridtolerance="10000" guidetolerance="10" objecttolerance="10" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="0.64" inkscape:cx="195.9221" inkscape:cy="335.3072" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" inkscape:window-width="640" inkscape:window-height="675" inkscape:window-x="44" inkscape:window-y="44" /> <metadata id="metadata7"> <rdf:RDF> <cc:Work rdf:about=""> <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> </cc:Work> </rdf:RDF> </metadata> <g inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1"> <rect style="opacity:0.25480766;fill:#ff0000;fill-opacity:1;stroke:#000000;stroke-width:12.94795799;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" id="rect2383" width="150.87796" height="84.226181" x="18.221733" y="39.557121"> <text xml:space="preserve" style="font-size:56.0331955px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans" x="44.815186" y="114.0088" id="text2385" transform="scale(1.0054479,0.9945816)"><tspan sodipodi:role="line" id="tspan2387" x="44.815186" y="114.0088">text</tspan></text> </rect> </g> </svg> I'd expect to be able to see this in inkscape. The workaround is to put text on a layer above the box (the intent is that the box obscures the layers below it) and not try and get clever with nested tags. Shame it doesn't work though.

    Read the article

  • Should we put <input> inside <label>?

    - by metal-gear-solid
    I saw 2 example: on http://www.alistapart.com/articles/prettyaccessibleforms/ why they are using 2 method in first fieldset they are keeping input after labeland in 2nd fieldset they are keeping input after label. Why? <fieldset> <legend>Delivery Details</legend> <ol> <li> <label for="name">Name<em>*</em></label> <input id="name" /> </li> <li> <label for="address1">Address<em>*</em></label> <input id="address1" /> </li> <li> <label for="address2">Address 2</label> <input id="address2" /> </li> <li> <label for="town-city">Town/City</label> <input id="town-city" /> </li> <li> <label for="county">County<em>*</em></label> <input id="county" /> </li> <li> <label for="postcode">Postcode<em>*</em></label> <input id="postcode" /> </li> <li> <fieldset> <legend>Is this address also your invoice » address?<em>*</em></legend> <label><input type="radio" » name="invoice-address" /> Yes</label> <label><input type="radio" » name="invoice-address" /> No</label> </fieldset> </li> </ol> </fieldset> why they are sometime keeping input after label and sometime inside?

    Read the article

  • Load on page inside another onClick

    - by Robin I Knight
    Hello, I need to include the content, scripts, forms and dynamic abilities of one page in another onClick. Take a look at http://www.divethegap.com/scuba-diving-programmes-dive-the-gap/dahab-master-scuba-diver.html Then follow one of the links that says 'Beginner' 'Open Water Diver' etc.... You will find a PHP page with a series of options. It is an adaption of the wordpress blog system to produce only specific options for specific programmes by considering each type of each diving programme a category and then displaying only results from that category. You will see that each option is also a collapsible panel and there are also several javascripts that calculate durations, quantities and prices. There is also a validating webform at the end. Now go back to the first page. What I would like to do is include all the content from the second page after the main header inside tabbed panels on the first page so that the customers can immidietly see everything that is included. Essentially the options on the first page would become a series of tabs. The only way I can see to do this is with an iFrame as each option would need a unique URL ending (that is .php?cat=26 or .php?cat=27). THe problem is that the collapsible panels will not work with an iFrame as the iFrame will not resize when the panels open. There were also some calculation problems, but I think that was more down to me staring at the screen for the last 3 hours not remembering to include everything. I have tried it with resizing iframe SSI scripts and have got nowhere. I tried actually embedding it in the page better with a ajax script, but that left behind all the scripts that make it work. I checked with full URL's on everything and it would not take work with any scripts. I know that you could just make the whole page reload but then the user would be at the top of the page again, and even if another script was applied to slowly bring them down again it would not be anything near as easy to use as if it was like tabbed panels. Any ideas. Kind Regards,

    Read the article

  • Hotfixing Code running inside Web Container with Groovy

    - by raoulsson
    I have a webapp running that has a bug. I know how to fix it in the sources. However I cannot redeploy the app as I would have to take it offline to do so. (At least not right now). I now want to fix the code "at runtime". Surgery on the living object, so to speak. The app is implemented in Java and is build on top of Seam. I have added a Groovy Console to the app previous to the last release. (A way to run arbitrary code at runtime) The normal way of adding behaviour to a class with Groovy would be similar to this: String.metaClass.foo= { x -> x * x } println "anything".foo(3) This code added the method foo to java.lang.String and prints 9. I can do the same thing with classes running inside my webapp container. New instances will thereafter show the same behaviour: com.my.package.SomeService.metaClass.foo= { x -> x * x } def someService = new com.my.package.SomeService() println someService.foo(3) Works as excpected. All good so far. My problem is now that the container, the web framework, Seam in this case, has already instantiated and cached the classes that I would like to manipulate (that is change their behaviour to reflect my bug fix). Ideally this code would work: com.my.package.SomeService.metaClass.foo= { x -> x * x } def x = org.jboss.seam.Component.getInstance(com.my.package.SomeService) println x.foo(3) However the instantiation of SomeService has already happened and there is no effect. Thus I need a way to make my changes "sticky". Has the groovy magic gone after my script has been run? Well, after logging out and in again, I can run this piece of code and get the expected result: def someService = new com.my.package.SomeService() println someService.foo(3) So the foo method is still around and it looks like my change has been permanent... So I guess the question that remains is how to force Seam to re-instantiate all its components and/or how to permanently make the change on all living instances...?

    Read the article

  • ASP.net: Radio Button Not Maintaining Selection After Postback, Inside DIV/Thickbox

    - by jlrolin
    I have a set of radio buttons inside a hidden DIV. <div id="reports" style="display:none;"> <center> <br /> <table cellpadding="4" cellspacing="0"> <tr> <td class="label"> Report Type::&nbsp; </td> <td class="value"> <asp:RadioButton ID="rbReportTypeCust" runat="server" Text="By Customer" Enabled="True" Checked="True" GroupName="rbType" />&nbsp;<asp:RadioButton ID="rbReportTypeProg" runat="server" Text="By Program" Enabled="True" GroupName="rbType" /> </td> </tr> <tr> <td class="label"> Customer:&nbsp; </td> <td class="value"> <asp:DropDownList ID="ddlCustomer" runat="server" /> </td> </tr> <tr> <td class="label"> Program Group::&nbsp; </td> <td class="value"> <asp:DropDownList ID="ddlProgramGroups" runat="server" /> </td> </tr> </table> <br /> <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="doPostBack(this);" /> </center> </div> The DIV is displayed using Thickbox as a modal popup. The doPostback javascript function posts the button click back, and hits btnSubmit_Click where a report is then generated. If I see if a radio button is checked, it's always rbReportTypeCust.checked = True, never the rbReportTypeProg.checked = True even if I click it. Any suggestions?

    Read the article

  • Radio button inside anchor element is reset after jQuery click handler

    - by GrievousAngel
    I have a situation where an element, of type radio, is contained in an element. The anchor element has a href but I want to override that behaviour by adding a jQuery 'click' handler to the element. The click handler makes the radio button inside it the selected one within the group. This all works when the anchor is clicked, however, when the radio button is clicked it appears that jQuery resets the selected radio to the previously selected one! Here is a the simplified page that duplicates the issue: <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#a1").click(function(event) { anchorClicked("a1"); return false; }); $("#a2").click(function(event) { anchorClicked("a2"); return false; }); }); function anchorClicked(anchorId) { $('#' + anchorId + ' input:radio').attr("checked", true); alert("Look at what is selected and what happens after the event when this dialog is closed!"); } </script> </head> <body> <form> <ul> <li id="li1"> <a id="a1" href="javascript:alert('default functionality')"> <input value="1" name="rb" type="radio" id="rb1"> <span>Details 1</span> </a> </li> <li id="li2"> <a id="a2" href="javascript:alert('default functionality')"> <input value="2" name="rb" type="radio" id="rb2"> <span>Details 2</span> </a> </li> </ul> </form> </body> Does anyone have any idea how I can prevent jQuery for resetting the radio button?

    Read the article

  • disabling dropdownlist inside a gridview based on value selected on another dropdownlist inside the gridview from javascript or jquery

    - by Joy
    what i m trying is i hav two dropdownlists inside the gridview... namely say ddonsiteoffsite and ddhours... now what i want is if the selectedtext of ddonsiteoffsite is "onsite" the ddhours should b disabled... i tried the code snippet but ... its not disabling the ddhours... can someone help me please.. <asp:TemplateColumn HeaderText=" OnSite/OffSite" > <ItemTemplate> <asp:DropDownList ID="ddOnsiteOffside" runat="server" onchange="ToggleOnOff(this)"><asp:ListItem Text = "Offsite" Value="Offsite"></asp:ListItem> <asp:ListItem Text = "Onsite" Value="Onsite"></asp:ListItem> </asp:DropDownList> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn> <ItemTemplate> <asp:DropDownList ID="ddhours" runat="server"> <asp:ListItem Text = "1" Value="1" ></asp:ListItem> <asp:ListItem Text = "2" Value="2" ></asp:ListItem> <asp:ListItem Text = "3" Value="3" ></asp:ListItem> <asp:ListItem Text = "4" Value="4" ></asp:ListItem> <asp:ListItem Text = "5" Value="5" ></asp:ListItem> <asp:ListItem Text = "6" Value="6" ></asp:ListItem> <asp:ListItem Text = "7" Value="7" ></asp:ListItem> <asp:ListItem Text = "8" Value="8" ></asp:ListItem> <asp:ListItem Text = "9" Value="9" ></asp:ListItem> </asp:DropDownList> </ItemTemplate> </asp:TemplateColumn> and the corresponding javascript i am using is : enter code here function ToggleOnOff(ddonoff) { var row = chk.parentNode.parentNode; if(ddonoff.value=="Onsite") { row.getElementsByTagName("ddhours")[0].disabled = true; } else row.getElementsByTagName("ddhours")[0].disabled = false; } can someone help to achieve this ?? using javascript or jquery ? i m not understanding where i went wrong ...

    Read the article

  • Memory Leak with jQuery UI inside UpdatePanel in ie7

    - by Ryan
    I have a fairly complex asp.net page based on UpdatePanels and jQuery UI. Unfortunately, when the panels update, the jQuery UI widgets leak memory like crazy in ie7, even if I manually 'destroy' them. Does anyone know a technique/patch to prevent these leaks? I've created a simple example page with a slider inside an UpdatePanel. Just click the 'Leak' button and refresh the page to see the leak in sieve. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Leak2.aspx.cs" Inherits="Leak2" %> <%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Leak</title> <link type="text/css" href="/jquery/css/custom-theme/jquery-ui-1.7.2.custom.css" rel="Stylesheet" /> <script type="text/javascript" src="/jquery/js/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="/jquery/js/jquery-ui-1.7.2.custom.min.js"></script> </head> <body> <form id="form1" runat="server"> <div> <script type="text/javascript"> function initializeSlider() { $(".slider").slider({ min: 0, max: 100, value: 100, step: 5 }); } $(document).ready(function() { initializeSlider(); Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function() { initializeSlider(); }); }); </script> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <div style="width: 300px;"> <div class="slider"></div> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Leak" /> </div> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html>

    Read the article

  • POST parameters strangely parsed inside phantomjs

    - by user61629
    I am working with PHP/CURL and would like to send POST data to my phantomjs script, by setting the postfields array below: In my php controller I have: $data=array('first' => 'John', 'last' => 'Smith'); $url='http://localhost:7788/'; $output = $this->my_model->get_data($url,$data); In my php model I have: public function get_data($url,$postFieldArray) { $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, $postFieldArray); curl_setopt($ch, CURLOPT_URL, $url); $output = curl_exec($ch); In my phantomJS script that I am running locally I have: // import the webserver module, and create a server var server = require('webserver').create(); var port = require('system').env.PORT || 7788; console.log("Start Application"); console.log("Listen port " + port); // Create serever and listen port server.listen(port, function(request, response) { // Print some information Just for debbug console.log("We got some requset !!!"); console.log("request method: ", request.method); // request.method POST or GET if(request.method == 'POST' ){ console.log("POST params should be next: "); console.log("POST params: ",request.post); exit; } I first start and run the phantomjs script (myscript.js) from the command line, then I run my php script. The output is: $ phantomjs.exe myscript.js Start Application Listen port 7788 null We got some requset !!! request method: POST POST params should be next: POST params: ------------------------------e70d439800f9 Content-Disposition: form-data; name="first" John ------------------------------e70d439800f9 Content-Disposition: form-data; name="last" Smith ------------------------------e70d439800f9-- I'm confused about the the output. I was expecting something more like: first' => 'John', 'last' => 'Smith Can someone explain why it looks this way? How can I parse the request.post object to assign to variables inside myscript.js

    Read the article

  • Accessing parent-level controls from inside a ComboBox's child controls

    - by eponymous23
    I have XAML similar to this: <ListBox ItemsSource="{Binding SearchCriteria, Source={StaticResource model}}" SelectionChanged="cboSearchCriterionType_SelectionChanged"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Name="spCriterion" Orientation="Horizontal" Height="20"> <ComboBox Name="cboSearchCriterionType" Width="120" SelectionChanged="cboSearchCriterionType_SelectionChanged"> <ComboBox.Items> <ComboBoxItem IsSelected="True" Content="Anagram Match" /> <ComboBoxItem Content="Pattern Match" /> <ComboBoxItem Content="Subanagram Match" /> <ComboBoxItem Content="Length" /> <ComboBoxItem Content="Number of Vowels" /> <ComboBoxItem Content="Number of Anagrams" /> <ComboBoxItem Content="Number of Unique Letters" /> </ComboBox.Items> </ComboBox> <TextBox x:Name="SearchSpec" Text="{Binding SearchSpec}" /> <TextBox x:Name="MinValue" Text="{Binding MinValue}" Visibility="Collapsed" /> <TextBox x:Name="MaxValue" Text="{Binding MaxValue}" Visibility="Collapsed" /> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> As you can tell from the markup, I have a listbox that is bound to a collection of SearchCriterion objects (collectively contained in a SearchCriteria object). The idea is that the user can add/remove criterion items from the criteria, each criterion is represented by a listbox item. Inside the listbox item I have a combobox and three textboxes. What I'm trying to do is change the visibility of the TextBox controls depending on the item that is selected in the ComboBox. For example, if the user selects "Pattern Match" then I want to show only the first textbox and hide the latter two; conversely, if the user selects "Length" or any of the "Number of..." items, then I want to hide the first TextBox and show the latter two. What is the best way to achieve this? I was hoping to do something simple in the SelectionChanged event handler for the listbox but the textbox controls are presumably out of the SelectionChanged event's scope. Do I have to programmatically traverse the control hierarchy and find the controls?

    Read the article

  • buttons inside scrollviewer problem

    - by Miroslav Valchev
    Hello, everyone. I couldn't find a solution to my problem eventhough I believe that others have come across this too. Basically, there are like twenty buttons in a wrap panel, which is inside a scrollviewer. The problem is that when I want to scroll the list, the click event fires the triggers. Really would appreciate help on this one. <ScrollViewer> <ScrollViewer.Content> <toolkit:WrapPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Top" Width="420"> <Button Style="{StaticResource imageButtonStyle}" > <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <cmd2:EventToCommand Command="{Binding SelectCommand, Mode=OneWay}" CommandParameterValue="1" /> </i:EventTrigger> </i:Interaction.Triggers> </Button> <Button Style="{StaticResource imageButtonStyle}"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <cmd2:EventToCommand Command="{Binding SelectCommand, Mode=OneWay}" CommandParameterValue="2" /> </i:EventTrigger> </i:Interaction.Triggers> </Button> <Button Style="{StaticResource imageButtonStyle}"> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseEnter"> <cmd2:EventToCommand Command="{Binding SelectCommand, Mode=OneWay}" CommandParameterValue="3" /> </i:EventTrigger> </i:Interaction.Triggers> </Button> <Button Style="{StaticResource imageButtonStyle}"> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseEnter"> <cmd2:EventToCommand Command="{Binding SelectCommand, Mode=OneWay}" CommandParameterValue="4" /> </i:EventTrigger> </i:Interaction.Triggers> </Button> </toolkit:WrapPanel> </ScrollViewer.Content>

    Read the article

  • Selenium navigation inside foreach loop

    - by smudgedlens
    I am having an issue with navigation. I get a list of rows from an html table. I iterate over the rows and scrape information from them. But there is also a link on the row that I click to go to more information related to the row to scrape. Then I navigate back to the page with the original table. This works for the first row, but for the subsequent rows, it throws an exception. I look at my row collection after the first time the link inside a row is clicked, and none of them have the correct values like they did before I clicked the link. I believe that there is something going on when I navigate to a different URL that I'm not getting. My code is below. How do I get this working so I can iterate over the parent table, click the links in each row, navigate to the child table, but still continue iterating over the rows in the parent table? private List<Document> getResults() { var documents = new List<Document>(); //Results IWebElement docsTable = this.webDriver.FindElements(By.TagName("table")) .Where(table => table.Text.Contains("Document List")) .FirstOrDefault(); var validDocRowRegex = new Regex(@"^(\d{3}\s+)"); var docRows = docsTable.FindElements(By.TagName("tr")) .Where(row => //It throws an exception with .FindElement() when there isn't one. row.FindElements(By.TagName("td")).FirstOrDefault() != null && //Yeah, I don't get this one either. I negate the match and so it works?? !validDocRowRegex.IsMatch( row.FindElement(By.TagName("td")).Text)) .ToList(); foreach (var docRow in docRows) { //Todo: find out why this is crashing on some documents. var cells = docRow.FindElements(By.TagName("td")); var document = new Document { DocID = Convert.ToInt32(cells.First().Text), PNum = Convert.ToInt32(cells[1].Text), AuthNum = Convert.ToInt32(cells[2].Text) }; //Go to history for the current document. cells.Where(cell => cell.FindElements(By.TagName("a")).FirstOrDefault() != null) .FirstOrDefault().Click(); //Todo: scrape child table. this.webDriver.Navigate().Back(); } return documents; }

    Read the article

  • form inside tabview doesn't work

    - by user3536737
    i am working with jsf and primefaces , and here is what 've tried well i want to creat a tabview that get data from an arraylist in my bean i get for exemple 4 tabs , and inside each one i've created a hidden panel where i have a form with 2 input text to update informations , do i display the panel when i click on the second button Update , after that my panel is not hidden anymore , and i set the new values and click on the second button to update the informations , the problem is that the updating and the execution is working only for the first tab , it means when i try to update the new informations it works for the first one and for the other tabs it doesn't here is the code <p:tab title="#{rr.nom_ressource}"> <h:panelGrid> <h:graphicImage value="Ressources/images/emp.jpg" style="vertical-align:middle" /> <span style="font-size:15px; width:170px; display:inline-block;"> Nom : #{rr.nom_ressource} Type: #{rr.type_ressource} Specification: #{rr.experience} </span> <h:commandButton image="Ressources/images/delete.jpg" actionListener="#{SelectBean.act}" update=":form" style="vertical-align:middle" > Update </h:commandButton> <h:commandButton update=":outPanel" actionListener="#{SelectBean.mod1()}" image="Ressources/images/update.png" style="vertical-align:middle" > Modifier </h:commandButton> <h:form id="form111"> <p:growl id="growl" showDetail="true" sticky="true" /> <p:panel rendered ="#{SelectBean.bol}" closable="true" toggleable="true" id="outPanel" styleClass="outPanel" widgetVar="outpanel"> <h:outputLabel value="Nom " /> <h:inputText value="#{SelectBean.nom}" /> <br/> <h:outputLabel value="Experience " /> <h:inputText value="#{SelectBean.exp}" /> <br/> <h:commandButton value="Update" action="#{SelectBean.done}"/> </p:panel> </h:form> </h:panelGrid> </p:tab> for my managedbean the code is correct i think the problem is here

    Read the article

  • Can <Setter.Value> have multiple grids inside it

    - by Subhen
    Hi, I want to define the background for my application in App.XAML. The background was previously defined in another xaml page,which have multiple Grids inside it like following: <Grid x:Key="GridGeneric" d:LayoutOverrides="Width, Height"> <Grid.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF00172E" Offset="1"/> <GradientStop Color="#FF004074" Offset="0.433"/> <GradientStop Color="#FF081316"/> <GradientStop Color="#FF001D3F" Offset="0.215"/> <GradientStop Color="#FF002043" Offset="0.818"/> <GradientStop Color="#FF003B6C" Offset="0.642"/> </LinearGradientBrush> </Grid.Background> <Grid> <Grid.Background> <RadialGradientBrush RadiusY="0.973" GradientOrigin="0.497,-0.276" RadiusX="1.003"> <GradientStop Color="#FFB350EE" Offset="0"/> <GradientStop Color="#001D3037" Offset="0.847"/> </RadialGradientBrush> </Grid.Background> </Grid> ------ ----- </Grid> Now I want to place the same in my App.xaml like following: <Style x:Key="backgroundStyle" TargetType="Grid"> <Setter Property="Background"> <Setter.Value> <Grid> <Grid.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FF00172E" Offset="1"/> <GradientStop Color="#FF004074" Offset="0.433"/> <GradientStop Color="#FF081316"/> <GradientStop Color="#FF001D3F" Offset="0.215"/> <GradientStop Color="#FF002043" Offset="0.818"/> <GradientStop Color="#FF003B6C" Offset="0.642"/> </LinearGradientBrush> </Grid.Background> <Grid> <Grid.Background> <RadialGradientBrush RadiusY="0.973" GradientOrigin="0.497,-0.276" RadiusX="1.003"> <GradientStop Color="#FFB350EE" Offset="0"/> <GradientStop Color="#001D3037" Offset="0.847"/> </RadialGradientBrush> </Grid.Background> </Grid> --------- --------- </Grid> </Setter.Value> </Setter> </Style> But While doing this I am getting the following Exception.

    Read the article

  • WP7 Button inside ListBox only "clicks" every other press

    - by Zik
    I have a button defined inside of a DataTemplate for my list box. <phone:PhoneApplicationPage.Resources> <DataTemplate x:Key="ListTemplate"> <Grid Margin="12,12,24,12"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Button Grid.Column="0" Name="EnableDisableButton" Click="EnableDisableButton_Click" BorderBrush="Transparent"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Image Grid.Row="0" Source="\Images\img.dark.png" Width="48" Height="48" Visibility="{StaticResource PhoneDarkThemeVisibility}" /> <Image Grid.Row="0" Source="\Images\img.light.png" Width="48" Height="48" Visibility="{StaticResource PhoneLightThemeVisibility}" /> <Rectangle Grid.Row="1" Width="48" Height="8" Fill="{Binding CurrentColor}" RadiusX="4" RadiusY="4" /> </Grid> </Button> <Grid Grid.Column="1"> <... more stuff here ...> </Grid> </Grid> </DataTemplate> </phone:PhoneApplicationPage.Resources> What I'm seeing is that the first time I press the button, the Click event fires. The second time I press it, it does not fire. Third press, fires. Fourth press, does not fire. Etc. Originally I had it bound to a command but that was behaving the same way. (I put a Debug.WriteLine() in the event handler so I know when it fires.) Any ideas? It's really odd that the click event only fires every other time.

    Read the article

  • Multisites Network SEO::Can self-referencing canonical tag(rel="canonical") inside article improve google rating?

    - by user5674576
    Hi, Can self-referencing canonical tag(rel="canonical") inside article improve google rating? The Case: Company have 40 sites with original content and 1 main site with some of 40 sites articles. Main site have rel="canonical" in each article Should article in original site have also rel="canonical" for self-referencing? example: inside main network site(reference to other site):<link href="http://site7.com/article25" rel="canonical" /> inside original network site(self-reference):<link href="http://site7.com/article25" rel="canonical"/> Thanks in advance

    Read the article

  • Ruby on rails model and controllers inside of different namespaces

    - by Nelson LaQuet
    OK. This is insane. I'm new to RoR and I really want to get into it as everything about it that I have seen so far makes it more appealing to the type of work that I do. However, I can't seem to accomplish a very simple thing with RoR. I want these controlers: /admin/blog/entries (index/show/edit/delete) /admin/blog/categories (index/show/edit/delete) /admin/blog/comments (index/show/edit/delete) ... and so on And these models: Blog::Entry (table: blog_entries) Blog::Category (table: blog_categories) Blog::Comments (table: blog_comments) ... and so on Now, I have already gone though quite a bit of misery to make this work. My first attempt was with generating scaffolding (I'm using 2.2.2). I generated my scaffolding, but had to move my model, then fix the references to the model in my controller (see http://stackoverflow.com/questions/903258/ruby-on-rails-model-inside-namespace-cant-be-found-in-controller). That is already a big of a pain, but hey, I got it to work. Now though form_for won't work and I cannot figure out how to use the url helpers (I have no idea what these are called... they are the automatically generated methods that return URLs to controllers associated with a model). I cannot figure out what their name is. My model is Blog::Entries. I have tried to mess with the route.rb's map's resource method, but no luck. When I attempt to use form_for with my model, I get this error undefined method `blog_entries_path' for #<ActionView::Base:0xb6848080> Now. This is really quite frustrating. I am not going to completely destroy my code's organization in order to use this framework, and if I cannot figure out how to accomplish this simple task (I have been researching this for at least 5 hours) then I simply cannot continue. Are there any ideas on how to accomplish this? Thanks EDIT Here are my routes: admin_blog_entries GET /admin_blog_entries {:controller=>"admin_blog_entries", :action=>"index"} formatted_admin_blog_entries GET /admin_blog_entries.:format {:controller=>"admin_blog_entries", :action=>"index"} POST /admin_blog_entries {:controller=>"admin_blog_entries", :action=>"create"} POST /admin_blog_entries.:format {:controller=>"admin_blog_entries", :action=>"create"} new_admin_blog_entry GET /admin_blog_entries/new {:controller=>"admin_blog_entries", :action=>"new"} formatted_new_admin_blog_entry GET /admin_blog_entries/new.:format {:controller=>"admin_blog_entries", :action=>"new"} edit_admin_blog_entry GET /admin_blog_entries/:id/edit {:controller=>"admin_blog_entries", :action=>"edit"} formatted_edit_admin_blog_entry GET /admin_blog_entries/:id/edit.:format {:controller=>"admin_blog_entries", :action=>"edit"} admin_blog_entry GET /admin_blog_entries/:id {:controller=>"admin_blog_entries", :action=>"show"} formatted_admin_blog_entry GET /admin_blog_entries/:id.:format {:controller=>"admin_blog_entries", :action=>"show"} PUT /admin_blog_entries/:id {:controller=>"admin_blog_entries", :action=>"update"} PUT /admin_blog_entries/:id.:format {:controller=>"admin_blog_entries", :action=>"update"} DELETE /admin_blog_entries/:id {:controller=>"admin_blog_entries", :action=>"destroy"} DELE

    Read the article

  • InputText inside Primefaces dataTable is not refreshed

    - by robson
    I need to have inputTexts inside datatable when form is in editable mode. Everything works properly except form cleaning with immediate="true" (without form validation). Then primefaces datatable behaves unpredictable. After filling in datatable with new data - it still stores old values. Short example: test.xhtml <h:body> <h:form id="form"> <p:dataTable var="v" value="#{test.list}" id="testTable"> <p:column headerText="Test value"> <p:inputText value="#{v}"/> </p:column> </p:dataTable> <h:dataTable var="v" value="#{test.list}" id="testTable1"> <h:column> <f:facet name="header"> <h:outputText value="Test value" /> </f:facet> <p:inputText value="#{v}" /> </h:column> </h:dataTable> <p:dataTable var="v" value="#{test.list}" id="testTable2"> <p:column headerText="Test value"> <h:outputText value="#{v}" /> </p:column> </p:dataTable> <p:commandButton value="Clear" actionListener="#{test.clear()}" immediate="true" update=":form:testTable :form:testTable1 :form:testTable2"/> <p:commandButton value="Update" actionListener="#{test.update()}" update=":form:testTable :form:testTable1 :form:testTable2"/> </h:form> </h:body> And java: import java.io.Serializable; import java.util.ArrayList; import java.util.List; import javax.annotation.PostConstruct; import javax.faces.bean.ViewScoped; import javax.inject.Inject; import javax.inject.Named; @Named @ViewScoped public class Test implements Serializable { private static final long serialVersionUID = 1L; private List<String> list; @PostConstruct private void init(){ update(); } public List<String> getList() { return list; } public void setList(List<String> list) { this.list = list; } public void clear() { list = new ArrayList<String>(); } public void update() { list = new ArrayList<String>(); list.add("Item 1"); list.add("Item 2"); } } In the example above I have 3 configurations: 1. p:dataTable with p:inputText 2. h:dataTable with p:inputText 3. p:dataTable with h:outputText And 2 buttons: first clears data, second applies data Workflow: 1. Try to change data in inputTexts in p:dataTable and h:dataTable 2. Clear data of list (arrayList of string) - click "clear" button (imagine that you click cancel on form because you don't want to store data to database) 3. Load new data - click "update" button (imagine that you are openning new form with new data) Question: Why p:dataTable with p:inputText still stores manually changed data, not the loaded ones? Is there any way to force p:dataTable to behaving like h:dataTable in this case?

    Read the article

  • Get the touch position inside the imageview in android

    - by Manikandan
    I have a imageview in my activity and I am able to get the position where the user touch the imageview, through onTouchListener. I placed another image where the user touch over that image. I need to store the touch position(x,y), and use it in another activity, to show the tags. I stored the touch position in the first activity. In the first activity, my imageview at the top of the screen. In the second activity its at the bottom of the screen. If I use the position stored from the first acitvity, it place the tag image at the top, not on the imageview, where I previously clicked in the first activity. Is there anyway to get the position inside the imageview. FirstActivity: cp.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub Log.v("touched x val of cap img >>", event.getX() + ""); Log.v("touched y val of cap img >>", event.getY() + ""); x = (int) event.getX(); y = (int) event.getY(); tag.setVisibility(View.VISIBLE); int[] viewCoords = new int[2]; cp.getLocationOnScreen(viewCoords); int imageX = x - viewCoords[0]; // viewCoods[0] is the X coordinate int imageY = y - viewCoords[1]; // viewCoods[1] is the y coordinate Log.v("Real x >>>",imageX+""); Log.v("Real y >>>",imageY+""); RelativeLayout rl = (RelativeLayout) findViewById(R.id.lay_lin); ImageView iv = new ImageView(Capture_Image.this); Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.tag_icon_32); iv.setImageBitmap(bm); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); params.leftMargin = x; params.topMargin = y; rl.addView(iv, params); Intent intent= new Intent(Capture_Image.this,Tag_Image.class); Bundle b=new Bundle(); b.putInt("xval", imageX); b.putInt("yval", imageY); intent.putExtras(b); startActivity(intent); return false; } }); In TagImage.java I used the following: im = (ImageView) findViewById(R.id.img_cam22); b=getIntent().getExtras(); xx=b.getInt("xval"); yy=b.getInt("yval"); im.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { int[] viewCoords = new int[2]; im.getLocationOnScreen(viewCoords); int imageX = xx + viewCoords[0]; // viewCoods[0] is the X coordinate int imageY = yy+ viewCoords[1]; // viewCoods[1] is the y coordinate Log.v("Real x >>>",imageX+""); Log.v("Real y >>>",imageY+""); RelativeLayout rl = (RelativeLayout) findViewById(R.id.lay_lin); ImageView iv = new ImageView(Tag_Image.this); Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.tag_icon_32); iv.setImageBitmap(bm); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( 30, 40); params.leftMargin =imageX ; params.topMargin = imageY; rl.addView(iv, params); return true; } });

    Read the article

  • Wrapping a paragraph inside a div?

    - by LOD121
    How do I make my paragraph wrap inside my div? It is currently overflowing outside of the div and I have no idea how to stop the paragraph from overflowing over the edge. I do not want a scroll bar with: overflow: scroll; and the other overflow options don't seem to help here either... I have the following code: div { width: 1200px; margin: 0 auto; } .container { overflow: hidden; } .content { width: 1000px; float: left; margin-left: 0; text-align: left; } .rightpanel { width: 190px; float: right; margin-right: 0; } <div class="container"> <div class="content"> <p>Some content flowing over more than one line</p> </div> <div class="rightpanel"> <!-- content --> </div> </div> Edit: <div class="container"> <div class="content"> <div class="leftcontent"> </div> <div class="newsfeed"> <div class="newsitem"> <p>Full age sex set feel her told. Tastes giving in passed direct me valley as supply. End great stood boy noisy often way taken short. Rent the size our more door. Years no place abode in no child my. Man pianoforte too solicitude friendship devonshire ten ask. Course sooner its silent but formal she led. Extensive he assurance extremity at breakfast. Dear sure ye sold fine sell on. Projection at up connection literature insensible motionless projecting.<br><br>Be at miss or each good play home they. It leave taste mr in it fancy. She son lose does fond bred gave lady get. Sir her company conduct expense bed any. Sister depend change off piqued one. Contented continued any happiness instantly objection yet her allowance. Use correct day new brought tedious. By come this been in. Kept easy or sons my it done.</p> </div> </div> </div> <div class="rightpanel"> </div>

    Read the article

  • onCommand on button not firing inside gridView??

    - by sah302
    This is really driving me crazy. I've got a button inside a gridview to remove that item from the gridview (its datasource is a list). I've got the list being saved to session anytime a change is being made to it, and on page_load check if that session variable is empty, if not, then set that list to bind to the gridview. Code Behind: Public accomplishmentTypeDao As New AccomplishmentTypeDao() Public accomplishmentDao As New AccomplishmentDao() Public userDao As New UserDao() Public facultyDictionary As New Dictionary(Of Guid, String) Public facultyList As New List(Of User) Public associatedFaculty As New List(Of User) Public facultyId As New Guid Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'If Not Session("associatedFaculty") Is Nothing Then' ' Dim associatedFacultyArray As User() = DirectCast(Session("associatedFaculty"), User())' ' associatedFaculty = associatedFacultyArray.ToList()' 'End If' Page.Title = "Add a New Faculty Accomplishment" ddlAccomplishmentType.DataSource = accomplishmentTypeDao.getEntireTable() ddlAccomplishmentType.DataTextField = "Name" ddlAccomplishmentType.DataValueField = "Id" ddlAccomplishmentType.DataBind() facultyList = userDao.getListOfUsersByUserGroupName("Faculty") For Each faculty As User In facultyList facultyDictionary.Add(faculty.Id, faculty.LastName & ", " & faculty.FirstName) Next If Not Page.IsPostBack Then ddlFacultyList.DataSource = facultyDictionary ddlFacultyList.DataTextField = "Value" ddlFacultyList.DataValueField = "Key" ddlFacultyList.DataBind() End If gvAssociatedUsers.DataSource = associatedFaculty gvAssociatedUsers.DataBind() End Sub Protected Sub deleteUser(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs) facultyId = New Guid(e.CommandArgument.ToString()) associatedFaculty.Remove(associatedFaculty.Find(Function(user) user.Id = facultyId)) Session("associatedFaculty") = associatedFaculty.ToArray() gvAssociatedUsers.DataBind() upAssociatedFaculty.Update() End Sub Protected Sub btnAddUser_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAddUser.Click facultyId = New Guid(ddlFacultyList.SelectedValue) associatedFaculty.Add(facultyList.Find(Function(user) user.Id = facultyId)) Session.Add("associatedFaculty", associatedFaculty.ToArray()) gvAssociatedUsers.DataBind() upAssociatedFaculty.Update() End Sub Protected Sub Delete(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs) End Sub End Class Markup: <asp:UpdatePanel ID="upAssociatedFaculty" runat="server" UpdateMode="Conditional"> <ContentTemplate> <p><b>Created By:</b> <asp:Label ID="lblCreatedBy" runat="server"></asp:Label></p> <p><b>Accomplishment Type: </b><asp:DropDownList ID="ddlAccomplishmentType" runat="server"></asp:DropDownList></p> <p><b>Accomplishment Applies To: </b><asp:DropDownList ID="ddlFacultyList" runat="server"></asp:DropDownList> &nbsp;<asp:Button ID="btnAddUser" runat="server" Text="Add Faculty" OnClientClick="incrementCounter();" /></p> <p> <asp:GridView ID="gvAssociatedUsers" runat="server" AutoGenerateColumns="false" GridLines="None" ShowHeader="false"> <Columns> <asp:BoundField DataField="Id" HeaderText="Id" Visible="False" /> <asp:TemplateField ShowHeader="False"> <ItemTemplate> <span style="margin-left: 15px;"> <p><%#Eval("LastName")%>, <%#Eval("FirstName")%> <asp:Button ID="btnUnassignUser" runat="server" CausesValidation="false" CommandArgument='<%# Eval("Id") %>' CommandName="Delete" OnCommand="deleteUser" Text='Remove' /></p> </span> </ItemTemplate> </asp:TemplateField> </Columns> <EmptyDataTemplate> <em>There are currently no faculty associated with this accomplishment.</em> </EmptyDataTemplate> </asp:GridView> </p> </ContentTemplate> </asp:UpdatePanel> Now here is the crazy part I am simply boggled by, if I uncomment the If Not Session... block of page_load, then deleteUser will never fire when btnUnassignUser is clicked. If I keep it commented out...it fires no problem, but then of course my list can never have more than one item since I am not loading the saved list from session into the gridview but just a fresh one. But the button click is being registered, because page_load is being stepped through again when I am viewing in debug mode, just deleteUser never fires. Why is this happening?? And how can I fix it??

    Read the article

  • Button with cell inside to big

    - by josh_24_2
    When i load it loads its cell with the button inside to big.Link to an example image: http://i.stack.imgur.com/x5j40.jpg. Also is there a way to change size of cells :) Please help me, If you need more info please must ask and I will be happy to give more information. <div class="content"> <?php $con = mysql_connect("","",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("", $con); $result = mysql_query("SELECT * FROM users ORDER by user_id"); echo "<link rel='stylesheet' href='<?php echo URL; ?>public/css/style.css' /><div class='CSSTableGenerator' > <table > <tr> <td> </td> <td> ID </td> <td > Username </td> <td> Email </td> <td> Admin </td> <td> User Active </td> </tr>"; while($row = mysql_fetch_array($result)) { if ($row['user_perm_level'] == "2") { $admin = 'Yes'; } else { $admin = 'No'; } if ($row['user_active'] == "1") { $active = 'Yes'; } else { $active = 'No'; } echo "<tr>"; echo "<td><input type='checkbox' name='1' value='1'></td>"; echo "<td>" . $row['user_id'] . "</td>"; echo "<td>" . $row['user_name'] . "</td>"; echo "<td>" . $row['user_email'] . "</td>"; echo "<td>" . $admin . "</td>"; echo "<td>" . $active . "</td>"; echo "</tr>"; } echo "</table></div>"; mysql_close($con); ?> </div> Thanks josh_24_2

    Read the article

  • Merging elements inside a xml.etree.ElementTree

    - by theAlse
    I have a huge test data like the one provided below (and yes I have no control over this data). Each line is actually 6 parts and I need to generate an XML based on this data. Nav;Basic;Dest;Smoke;No;Yes; Nav;Dest;Recent;Regg;No;Yes; Nav;Dest;Favourites;Regg;No;Yes; ... Nav;Dest using on board;By POI;Smoke;No;Yes; Nav;Dest using on board;Other;Regg;No;Yes; The first 3 elements on each line denotes "test suites"-XML element and the last 3 element should create a "test case"-XML element. I have successfully converted it into a XML using the following code: # testsuite (root) testsuite = ET.Element('testsuite') testsuite.set("name", "Tests") def _create_testcase_tag(elem): global testsuite level1, level2, level3, elem4, elem5, elem6 = elem # -- testsuite (level1) testsuite_level1 = ET.SubElement(testsuite, "testsuite") testsuite_level1.set("name", level1) # -- testsuite (level2) testsuite_level2 = ET.SubElement(testsuite_level1, "testsuite") testsuite_level2.set("name", level2) # -- testsuite (level3) testsuite_level2 = ET.SubElement(testsuite_level2, "testsuite") testsuite_level2.set("name", level3) # -- testcase testcase = ET.SubElement(testsuite_level2, "testcase") testcase.set("name", "TBD") summary = ET.SubElement(testcase, "summary") summary.text = "Test Type= %s, Automated= %s, Available=%s" %(elem4, elem5, elem6) with open(input_file) as in_file: for line_number, a_line in enumerate(in_file): try: parameters = a_line.split(';') if len(parameters) >= 6: level1 = parameters[0].strip() level2 = parameters[1].strip() level3 = parameters[2].strip() elem4 = parameters[3].strip() elem5 = parameters[4].strip() elem6 = parameters[5].strip() lines_as_list.append((level1, level2, level3, elem4, elem5, elem6)) except ValueError: pass lines_as_list.sort() for elem in lines_as_list: _create_testcase_tag(elem) output_xml = ET.ElementTree(testsuite) ET.ElementTree.write(output_xml, output_file, xml_declaration=True, encoding="UTF-8") The above code generates an XML like this: <testsuite name="Tests"> <testsuite name="Nav"> <testsuite name="Basic navigation"> <testsuite name="Set destination"> <testcase name="TBD"> <summary>Test Type= Smoke test Automated= No, Available=Yes</summary> </testcase> </testsuite> </testsuite> </testsuite> <testsuite name="Nav"> <testsuite name="Set destination"> <testsuite name="Recent"> <testcase name="TBD"> <summary> Test Type= Reggression test Automated= No, Available=Yes </summary> </testcase> </testsuite> </testsuite> </testsuite> </testsuite> ... This is all correct, but as you can see I have created a whole tree for each line and that is not what I need. I need to combine e.g. all testsuite with the same name into one testsuite and also perform that recursively. So the XML looks like this instead: <testsuite name="Tests"> <testsuite name="Nav"> <testsuite name="Basic navigation"> <testsuite name="Set destination"> <testcase name="TBD"> <summary>Test Type= Smoke test Automated= No, Available=Yes</summary> </testcase> </testsuite> <testsuite name="Recent"> <testcase name="TBD"> <summary> Test Type= Reggression test Automated= No, Available=Yes </summary> </testcase> </testsuite> </testsuite> </testsuite> </testsuite> I hope you can understand what I mean, but level1, level2 and level3 should be unique with testcases inside. How should I do this? Please do not suggest the use of any external libraries! I can not install new libraries in customer site. xml.etree.ElementTree is all I have. Thanks

    Read the article

< Previous Page | 34 35 36 37 38 39 40 41 42 43 44 45  | Next Page >