Wicket link - is adding a label necessary to set the text? - hyperlink

Currently, I do this:
<li><a wicket:id="link" href="#"><span wicket:id="name">jawa01</span></a></li>
and
item.add( new BookmarkablePageLink("link", ResourcePage.class)
.setParameter("name", item.getModelObject().getName())
.add( new Label("name", item.getModelObject().getName()) )
);
I want to do ommit the element:
<li><a wicket:id="link" href="#">...</a></li>
How should the java code look?
I expect something like
item.add( new BookmarkablePageLinkWithLabel(
"link", ResourcePage.class, item.getModelObject().getName())
.setParameter("name", item.getModelObject().getName())
);
Thanks, Ondra

This is not built into Wicket, with a couple of reasons presented here.
However, you can certainly make you own component out of what you currently do to make your life easier. The constructor would take both the model for the link and the model for the label.

Related

routerLinkActive id coupled with [ngClass]

Below web-link demonstrates the routerLinkActive id working when used as a boolean value for a distinct HTML element' [ngClass]
https://stackblitz.com/edit/routerlinkactivesimple?file=src%2Fapp%2Fapp.module.ts
In contrast the routerLinkActive id is not working with #angular/material instance below web-link, but the error disappears by commenting lines 5 and 6 , however not rectifying the usability of routerLinkActive id:
https://stackblitz.com/edit/mat-routerlinkactive?file=src%2Fapp%2Fnav%2Fnav.component.html
your second link has a lot of issues, the app-nav is not even used, so "commenting lines" is not enough to make it work..
but anyway
there is no issue with routerLinkActive, the problem is :
<button mat-button color="white" fxHide.xs *ngIf="true">
<span>
<a routerLink="city-list" routerLinkActive="active-link citNgClassList" #rla_clist="routerLinkActive"
[routerLinkActiveOptions]="{exact: true}">
<mat-icon class="mr">maps_home_work</mat-icon>
Cities
</a>
</span>
</button>
your link is inside a button..
remove the button, keep the "a" and it works
and what's the point of *ngIf="true" ?
Edit :
you can keep the button and remove the 'a' if you want to keep the button style (but it's bad usability wise to display link as button..), just put routerLink, routerLinkActive & routerLinkActiveOption on the button directly
Thanks, JiBi , for your observations. Indeed stripping off the material button wrapper of the links does not longer gives an error on the second StackBlitz link line 5 span , but it hurts to the over all page with styling in a bad way that breaks the harmony of the page that is not easy to substitute. I have removed some of the comments , that were left in place to give an easy idea of what I have tried.
The *ngIf= "true" of the buttons was meant to be a *ngIf= "!rla_clist" or *ngIf= "!rla_cform" so the button sender to the link will not displayed if I am on the link itself ,.....but this is another problem of which better solution I am awaiting.

AngularDart Passing Toggle Event from one component to another Component

From here :
https://github.com/dart-lang/angular_components_example/blob/master/example/app_layout_example/lib/app_layout_example.html
I want to split this template in two templates:
one for sidebar <material-drawer>, named for example sidebar_component.{dart,html}
one other for <div class="material-content">, named for example app_component.{dart,html}
Question:
How to reach <material-drawer> from sidebar_component, with <material-button icon class="material-drawer-button" (trigger)="drawer.toggle()"> into app_component?
Components are encapsulated on purpose. So there isn't a super easy way to reach into the encapsulation of one component from the other.
What you can do is create a passthrough from one component to the other.
<side-bar #sidebar></side-bar>
<app-component (openSideBar)="sidebar.toggle()"></app-component>
sidebar_component
#Component()
class SidebarComponent {
#ViewChild(MaterialPersistentDrawerDirective)
MaterialPersistentDrawerDirective drawer;
void toggle() => drawer.toggle();
}
app_component.dart
#Component()
class AppComponent {
final _openSideBar = StreamController<void>();
#Output()
Stream<void> openSideBar => _openSideBar.stream;
// This is getting called by the trigger of the button click
void onButtonClick() => _openSideBar.add();
}
I would say that for me passing all of these events feels like a bit of a smell. The components themselves are breaking encapsulation and so I wouldn't architect the app exactly like that.
I would probably have the contents of the drawer be a component, and perhaps the header and body depending on how complex they got. To have something more like this:
<material-drawer #drawer>
<side-bar *deferredContent></side-bar>
</material-drawer>
<div class="material-content">
<app-header class="material-header shadow" (triggerDrawer)="drawer.toggle()">
</app-header>
<router-outlet></router-outlet>
</div>
I find it better to keep the app-layout logic in the same components if possible and encapsulate the pieces of that. You could also pass the drawer as an input, but then you are making those highly coupled which I tend to try not to do.

Getting issue to generate Absolute Url's in MVC

Hi I have created a mvc website which is working fine with localhost if i am coding something like this:
<base href="http://localhost:5400/" />
<li><a class="home" href="/Home/Index/">Home</a></li>
<li class="wish"><a class="wishlist" href="/Products/Index/" id="wishlist-total">Products</a></li>
<li><a class="account" href="/Home/Contact/">Contact Us</a></li>
But now to run it on live if i am trying to changing this:
<base href="http://localhost:5400/" />
with this:
<base href="HttpContext.Current.Request.Url" />
then its actually taking full root url everytime.So whenever i am clicking on any menu and moves to next menu it regain previous menu path also.
For this issue i tried below code which is also not working.
<li>Home</li>
<li>Products</li>
<li> Contact</li>
According me this code will work,But if i am trying to pass "null" as third parameter then i gives error:
ERROR: 'null' is not declared. 'Null' constant is no longer supported; use 'System.DBNull' instead.
Can someone please suggest what i should need to change?
Thanks
Quick fix...
#Url.Action("Index", "Home")
There's no need to enter null as a parameter... if you want to indicate that a parameter can be null, then you need to define that in the route its self, and if the parameter is missing, then it will know that the value is null implicitly...
// http://yoursite/Example/{id}
[Route("~/Example/{id}"] // Can't be null
public ActionResult Example(string id){ return View(); }
// http://yoursite/ExampleTwo/
[Route("~/ExampleTwo/{id?} // Can be null
public ActionResult ExampleTwo(string id) { return View(); }
TLDR if you want more errors...
Your issue is actually indicating a much larger issue... it looks as if you're accepting a query from a URI directly into a SQL query... if you are doing that, you're opening yourself up to injection attacks and as much as a part of me feels that anyone who does that pretty much has it coming to them... I can't stand by and just say nothing... sanitize any data that you receive from the user, no matter where it's coming from, example
Remove all those magic strings... you shouldn't have any strings such as the one you just displayed...
// Bad...
<a class="home" href="/Home/Index/">
// Better...
<a class="home" href="#Url.Action("Index", "Home")">Home</a>
// Good
#Html.ActionLink("Home", "Index", "Home")

ActionLink MVC4 Razor with icon class

I have this code HTML:
<a class="tooltip-tip2 ajax-load" href="...."><i class="entypo-menu"></i><span>Page Example</span></a>
And I would use this:
#Html.ActionLink("Crea mensilizzazione " + s.nome, "CheckCredentials", "giornaliero", new { #class= "tooltip-tip2 ajax-load" , id=s.id, isScuole = false},null)
How can add the <i class="entypo-menu"></i> in this #HTML.ActionLink???
I don't think the ActionLink helper can accomplish this. but you can use #Url.Action() in custom markup to accomplish the same thing:
<a class="tooltip-tip2 ajax-load" href="#Url.Action("CheckCredentials", "giornaliero")"><i class="entypo-menu"></i><span>Page Example</span></a>
Url.Action basically just creates the URL for the link, not any of the markup related to building the link itself. So it can be used in all sorts of custom client-side code. (For example, another common use is to embed it in some JavaScript code to define an AJAX service URL.)
Edit: You can add route values exactly the same way as you do with #Html.ActionLink:
#Url.Action("CheckCredentials", "giornaliero", new { id = s.id, isScuole = false })

Kraken, Dust and Makara

<span id='sitemap'>
{#footer.sitemaps}
<a id="{id}" href="{url}">{#pre type="content" mode="json" key="footer.{id}"/}</a>
{/footer.sitemaps}
</span>
In the code, {id} is a property of one element in footer.sitemaps. I want Makara to get the key value dynamically using {id}. May I know how to do that?
See the discussion around this makara issue: https://github.com/krakenjs/makara/issues/36
Check this: https://github.com/mikesparr/Kraken_Example_i18n_Helper
You can use #bundleString helper rather than #pre.
So, you can use something like {#bundleString key="footer.{id}" bundle="your_data_properties_file name"}
You can do that by using the {#provide} tag. Here is an example using yours:
{#provide}
{#footer.sitemaps}
<a id="{id}" href="{url}">{footerMap[id]}</a>
{/footer.sitemaps}
{:footerMap}
{#pre type="content" mode="json" key="footer"/}
{/provide}
If your properties file looked like
footer.key1=SomeVal
footer.key2=AnotherVal
and your footer.sitemaps data object looked like
{
id: 'key1',
href: 'http://my/url
}
The result of running this would be
<a id="key1" href="http://my/url">SomeVal</a>

Resources